PHP 5 Case Sensitivity
PHP Case sensitivity
PHP functions, classes, core language keywords are case-insensitive. That means you can write classes, functions and keyword in any case.
For example, you can write echo construct in different ways like Echo, ECHO, echo or you can write date function like Date, DaTe, date.
PHP case sensitivity example
<?php echo "Welcome to PHP". "
"; ECHO "welcome ". "
"; Echo "php". "
"; echo Date("Y/m/d") . "
"; echo DATE("Y.m.d") . "
"; echo Date("Y-m-d"); ?>
You can write pre-defined function in any case let's take the example of rand() function.
Example of Case sensitivity
<?php $random_number =rand(); echo "
Random number = ". $random_number; $random_number1 =RAND(); echo "
Random number = ". $random_number1; $random_number2 =Rand(); echo "
Random number = ". $random_number2; ?>
Random number = 832972821
Random number = 1472710575
In the above example there are three variable named $random_number, $random_number1, $random_number2 and all three hold the rand function in different case.
There will be no error message, all executed properly and give proper result as shown above.
PHP case sensitive variable
PHP variables are case sensitive so you cannot use $NAME as the place of $name.
Example of PHP case sensitive variable
<?php $name_of_car = "Audi R8"; echo $NAME_OF_CAR; ?>
$name_of_car and $NAME_OF_CAR are not same so that error message will come.
PHP White Space
White space between lines ignored by the PHP that means it's fine to leave several new lines.
PHP white space example
<?php print "Bye bye "."
"; //Leaving some blank lines after the PHP code Print " What's Up"."
"; echo date("Y-m-d")."
You can leave multiple lines in your PHP script as shown in the above example.
PHP variable white space
In case of variable you cannot leave blank (white space).
Example of PHP variable white space
<?php $name of car = "Audi R8"; echo $NAME OF CAR; ?>