PHP’s handling of case-sensitive issues is messy, and problems may occasionally occur when writing code, so this article will summarize it below. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.
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
<?php $abc = 'abcd'; echo $abc; //输出 'abcd' echo $aBc; //无输出 echo $ABC; //无输出
2. Constant names are case-sensitive by default and are usually written in uppercase
<?php define("ABC","Hello World"); echo ABC; //输出 Hello World echo abc; //输出 abc
php.ini configuration item instructions are case-sensitive
For example, file_uploads = 1 cannot be written as File_uploads = 1
3. Function names, method names, and class names are not Case sensitive
But it is recommended to use the same name as when defined
<?php function show(){ echo "Hello World"; }
show(); //Output Hello World Recommended writing method
SHOW(); / /Output Hello World
<?php class cls{ static function func(){ echo "hello world"; } } Cls::FunC(); //输出hello world
4. Magic constants are not case-sensitive. It is recommended to use uppercase letters
including: __LINE__, __FILE__, __DIR__, __FUNCTION__, __CLASS__, __METHOD__, __NAMESPACE__.
<?php echo __line__; //输出 2 echo __LINE__; //输出 3
5, NULL, TRUE, FALSE are not case-sensitive
<?php $a = null; $b = NULL; $c = true; $d = TRUE; $e = false; $f = FALSE; var_dump($a == $b); //输出 boolean true var_dump($c == $d); //输出 boolean true var_dump($e == $f); //输出 boolean true
Summary:
In PHP, functions Names (custom and built-in functions), method names, class names, and keywords are not case-sensitive; but variable names are case-sensitive.
The above is the detailed content of Are php function names case sensitive?. For more information, please follow other related articles on the PHP Chinese website!