PHP | Case Sensitive
In PHP, keywords (e.g. if, else, while, echo, etc.), classes, functions, and user-defined functions are not case-sensitive but all variable names are case-sensitive.
If you defined function name in lowercase, but calling them in uppercase it will work fine.
In the example below, There are used three echo keywords in different ways yet the statements print the same output without giving any error:
<!DOCTYPE html>
<html>
<body>
<?php
ECHO "Hello PHP!<br>";
echo "Hello PHP!<br>";
ECho "Hello PHP!<br>";
?>
</body>
</html>
Let's see an example of a user-defined function. In the bellow example function sum() defined in lowercase and the function is called in three different ways yet all runs successfully
<!DOCTYPE html>
<html>
<body>
<?php
// function defined in lowercase
function sum($a, $b){
return $a + $b;
}
// function call
echo SUM(5, 10); // output 15
echo sum(2, 6); // output 8
echo SUm(4, 8); // output 12
?>
</body>
</html>
It is good practice to call a function as it appears in its definition.
In PHP, all variable names are case-sensitive. If you defined a variable in lowercase, then you need to use it in lowercase everywhere in the program.
Look at the example below; only the first statement will display the value of the $name variable and the rest two-variable throw errors. This is because $name, $NAME, and $NAme are treated as three different variables.
<!DOCTYPE html>
<html>
<body>
<?php
$name = "James";
echo $name . "<br>";
echo $NAME . "<br>";
echo $NAme . "<br>";
?>
</body>
</html>