Home > Backend Development > PHP Tutorial > Summary of PHP case-sensitive issues (practical)

Summary of PHP case-sensitive issues (practical)

WBOY
Release: 2016-07-25 08:59:10
Original
1041 people have browsed it
  1. $abc = 'abcd';
  2. echo $abc; //Output 'abcd'
  3. echo $aBc; //No output
  4. echo $ABC; //No output
  5. ?>
Copy code

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) example:

  1. define("ABC","Hello World");
  2. echo ABC; //Output Hello World
  3. echo abc; //Output abc
  4. ?>
Copy code

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. example:

  1. function show(){
  2. echo "Hello World";
  3. }
  4. show(); //Output Hello World Recommended writing method
  5. SHOW(); //Output Hello World
  6. ?> ;
Copy code

Example:

  1. class cls{

  2. static function func(){
  3. echo "hello world";
  4. }
  5. }

  6. Cls:: FunC(); //Output hello world

  7. ?>

Copy code

2. Magic constants are not case-sensitive, uppercase is recommended Includes: __LINE__, __FILE__, __DIR__, __FUNCTION__, __CLASS__, __METHOD__, __NAMESPACE__. example:

  1. echo __line__; //Output 2
  2. echo __LINE__; //Output 3
  3. ?>
Copy code

3. NULL, TRUE, FALSE are not case sensitive example:

  1. $a = null;
  2. $b = NULL;
  3. $c = true;
  4. $d = TRUE;
  5. $e = false;
  6. $f = FALSE;
  7. var_dump($ a == $b); //Output boolean true
  8. var_dump($c == $d); //Output boolean true
  9. var_dump($e == $f); //Output boolean true
  10. ?>
Copy code

4. Type coercion, case-insensitive include

  1. $a=1;
  2. var_dump($a); //Output int 1
  3. $b=(STRING)$a;
  4. var_dump($b); //Output string ' 1' (length=1)
  5. $c=(string)$a;
  6. var_dump($c); //Output string '1' (length=1)
  7. ?>
Copy code


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template