PHP for case sensitive problem processing is messy, write code may occasionally problem, so here is summed up.
But I am not encouraging everyone to use these rules. We recommend that you always adhere to the "case sensitive", follow the Uniform Code specifications.
1. Variable names are case-sensitive
Copy Code code as follows:
<?php
$ABC = ' ABCD ';
Echo $abc; Output ' ABCD '
Echo $aBc; No output
Echo $ABC; No output
2. Constant names are case-sensitive by default, and are usually written as uppercase
(but could not find a way to change this default configuration item, solve)
Copy Code code as follows:
<?php
Define ("ABC", "Hello World");
Echo ABC; Output Hello World
ECHO ABC; Output ABC
3. PHP.ini configuration item directives are case-sensitive
such as File_uploads = 1 cannot be written file_uploads = 1
4. Function name, method name, class name is case-insensitive
But it is recommended to use the same name as the definition
Copy Code code as follows:
<?php
Function Show () {
echo "Hello World";
}
Show (); Output Hello World recommended notation
Show (); Output Hello World
Copy Code code as follows:
<?php
Class cls{
static function func () {
echo "Hello World";
}
}
Cls::func (); Output Hello World
5. Magic constant case-insensitive, recommended uppercase
Include: __line__, __file__, __dir__, __function__, __class__, __method__, __namespace__.
Copy Code code as follows:
<?php
Echo __line__; Output 2
Echo __line__; Output 3
6. NULL, TRUE, false is case-insensitive
Copy Code code as follows:
<?php
$a = null;
$b = NULL;
$c = true;
$d = TRUE;
$e = false;
$f = FALSE;
Var_dump ($a = = $b); Output Boolean True
Var_dump ($c = = $d); Output Boolean True
Var_dump ($e = = $f); Output Boolean True
PHP variable names are case-sensitive, function names are case-insensitive, and are often overlooked in small details by novices, as tested below.
PHP variable name case sensitivity test:
Copy Code code as follows:
<?php
$AAA = "Jb51.net";
$AAA = "JB51." CN ";
echo $aaa. '-'. $AAA; jb51.net-jb51.cn
?>
PHP function name does not match case test:
Copy Code code as follows:
<?php
function bbb () {
Echo ' abc ';
}
function BBB () {
echo "ABC";
}
?>
The above code will be an error: (!) Fatal error:cannot redeclare BBB ()