Programming Tricks 1 - PHP and JS/CSS

Programming Tricks 1


When creating PHP scripts, there is a funny error that if there are spaces before the first <?php tag, the session information is sent before the php script is executed.

So if you get:
 [22-Sep-2019 12:09:17 America/New_York] PHP Warning:  session_start(): Cannot start session when headers already sent in /home/esceqrkk/groundstationdatabase/main.php on line 3
 And there is no code before that main.php file, it's due to the spaces.

Javascript + CSS

A super easy way to animate and control your CSS animations is to use css transitions, css variables and jquery all in one go for example:

JQuery side:
        var currentXTranslation = 0;
        $(document).ready(function () {
            $("#NavigateLeftButton").click(function(evt) {
                currentXTranslation += 100;

                $(':root').css('--current-x-translation', currentXTranslation + "vw"); 
CSS Side:
:root {
        --main-bg-color: #141414;
        --current-x-translation: 0vw;

    .Slide {
        transform: translateX(var(--current-x-translation));
        transition-property: transform;
        transition-duration: 3s;
This results in the "Slide" element's transform to be controlled by the JQuery, and the CSS to do the updating.


Popular posts from this blog

Ten Golden Usability Rules

Programming Adventures 2 - Unity3D Translation