PHP handles case-sensitive issues in disorder and may occasionally encounter issues when writing code. So here is a summary.
However, I do not encourage you to use these rules. We recommend that you always adhere to the "Case sensitivity" and follow the unified code specifications.
1. Variable names are case sensitive
Copy codeThe Code is as follows:
<? Php
$ Abc = 'abc ';
Echo $ abc; // output 'abc'
Echo $ aBc; // No output
Echo $ ABC; // No output
2. Constant names are case-sensitive by default and are generally written in uppercase.
(But the default configuration item cannot be changed)
Copy codeThe Code is as follows:
<? Php
Define ("ABC", "Hello World ");
Echo ABC; // output Hello World
Echo abc; // output abc
3. The php. ini configuration item command is case sensitive.
For example, file_uploads = 1 cannot be written as File_uploads = 1
4. The function name, method name, and class name are case-insensitive.
However, we recommend that you use the same name as the one defined in the definition.
Copy codeThe Code is as follows:
<? Php
Function show (){
Echo "Hello World ";
}
Show (); // output the recommended Hello World Statement
SHOW (); // output Hello World
Copy codeThe Code is as follows:
<? Php
Class cls {
Static function func (){
Echo "hello world ";
}
}
Cls: FunC (); // output hello world
5. The magic constants are case-insensitive. uppercase is recommended.
Including: __line _, _ FILE _, _ DIR _, _ FUNCTION _, _ CLASS _, _ METHOD _, and _ NAMESPACE __.
Copy codeThe Code is as follows:
<? Php
Echo _ line __; // output 2
Echo _ LINE __; // output 3
6. NULL, TRUE, and FALSE are case insensitive.
Copy codeThe Code is as follows:
<? Php
$ A = null;
$ B = NULL;
$ C = true;
$ D = TRUE;
$ E = false;
$ F = FALSE;
Var_dump ($ a = $ B); // outputs boolean true
Var_dump ($ c ==$ d); // outputs boolean true
Var_dump ($ e = $ f); // outputs boolean true
PHP variable names are case-sensitive. function names are case-insensitive and are often ignored by new users. The test is as follows.
PHP variable name case sensitive test:
Copy codeThe Code is as follows:
<? Php
$ Aaa = "jb51.net ";
$ AAA = "JB51.CN ";
Echo $ aaa. '-'. $ AAA; // jb51.net-JB51.CN
?>
PHP function name case-insensitive test:
Copy codeThe Code is as follows:
<? Php
Function bbb (){
Echo 'abc ';
}
Function BBB (){
Echo "Abc ";
}
?>
The above code will report an error :(! ) Fatal error: Cannot redeclare BBB ()