Home > Article > Backend Development > Summary of the issue of whether PHP is case sensitive
PHP is case sensitive for variables and constants. Class names and method names are not case-sensitive. It is not sensitive to null, false, true, etc., and is also sensitive to the configuration parameters in php.ini. This article summarizes the issues in this regard.
This article is a summary of whether PHP is case sensitive. However, it is recommended to always adhere to "case sensitivity" and follow unified coding standards. 1. Case sensitivity 1. Variable names are case-sensitive <?php /** * 大小写敏感 * edit bbs.it-home.org */ $abc ='abcd'; echo $abc; //输出 'abcd' echo $aBc; //无输出 echo $ABC; //无输出 ?> 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 it) <?php define("ABC","Hello World"); echo ABC; //输出 HelloWorld echo abc; //输出abc ?> 3, php.ini configuration item instructions are case sensitive For example, file_uploads = 1 cannot be written as File_uploads = 1 2. Case insensitive 1. Function names, method names, and class names are not case-sensitive, but it is recommended to use the same names as when they were defined. 2. Magic constants are not case-sensitive, uppercase is recommended Includes: __LINE__, __FILE__, __DIR__, __FUNCTION__, __CLASS__, __METHOD__, __NAMESPACE__. <?php echo __line__; //输出 2 echo __LINE__; //输出 3 //by bbs.it-home.org ?> 3. NULL, TRUE, and FALSE are not case-sensitive. The php function var_dump is used below. <?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 //by bbs.it-home.org ?> |