PHP Case-sensitivity

In PHP, keywords (e.g. if, else, while, echo, etc.), classes, functions, and user-defined functions are not case-sensitive.


In the example below, all three echo statements below are equal and legal:

<!DOCTYPE html>

<html>

    <body>

       <?php

              ECHO "Hello World!<br>";

             echo "Hello World!<br>";

             EcHo "Hello World!<br>";

       ?>

    </body>

</html>

Output:

Hello World!
Hello World!
Hello World!

Note: However; all variable names are case-sensitive!


Variables are the Case-sensitive. 

$color, $COLOR, and $coLOR are treated as three different variables:

<!DOCTYPE html>
<html>
    <body>

        <?php
        $color = "red";
        echo "My car is " . $color . "<br>";
        echo "My house is " . $COLOR . "<br>";
        echo "My boat is " . $coLOR . "<br>";
        ?>

    </body>
</html>

Post a Comment

0 Comments