• @stupidcasey
    link
    212 days ago

    You generally use them at the end of a line but it is more accurate to say you use them at the end of a statement but we usually put each statement on a single line so it is easy to make that mistake example:

    Tap for spoiler
    <?php
    $x = 5; // Semicolon ends the statement
    $y = 10; // Another statement ends here
    
    if ($x < $y) { // No semicolon needed here
        echo "x is less than y"; // Semicolon ends this statement
    }
    
    $x = $x + $y; // Statement ends here
    echo $x; // Outputs 15
    ?>