Home > Article > Backend Development > PHP case problem: function names and class names are not distinguished, variable names are distinguished_PHP tutorial
PHP’s handling of case-sensitive issues is messy, and problems may occasionally occur when writing code, so I’ll summarize it here.
But I am not encouraging everyone to use these rules. It is recommended that everyone always adhere to "case sensitivity" and follow unified coding standards.
1. Variable names are case-sensitive
2. Constant names are case-sensitive by default and are usually written in uppercase
(but I couldn’t find a configuration item that can change this default, please solve)
3. php.ini configuration item instructions are case-sensitive
For example, file_uploads = 1 cannot be written as File_uploads = 1
4. Function names, method names, and class names are not case-sensitive
But it is recommended to use the same name as when defined
show(); // Output Hello World recommended writing method
SHOW(); //Output Hello World
5. Magic constants are not case-sensitive, uppercase letters are recommended
including: __LINE__, __FILE__, __DIR__, __FUNCTION__, __CLASS__, __METHOD__, __NAMESPACE__.
6. NULL, TRUE and FALSE are not case sensitive
PHP variable names are case-sensitive, while function names are not case-sensitive. This is a small detail that is often overlooked by novices. The test is as follows.
PHP variable name case sensitivity test:
PHP function name case-insensitive test:
The above code will report an error: ( ! ) Fatal error: Cannot redeclare BBB()