Why, in PHP, are some predefined constants case-insensitive?

Why, in PHP, some predefined constants are case-insensitive (do not differentiate uppercase from Lowercase) and others are not?

Example 1:

echo __FILE__; // index.php

echo __file__; // index.php

echo __fiLE__; // index.php

Example 2:

echo PHP_EOL; \n

echo php_eol; // Use of undefined constant php_EOL - assumed 'php_eol' 

echo php_EOL; // Use of undefined constant php_EOL - assumed 'php_EOL' 

As it turns out, in the latter case it generates error, and in the first one it does not generate any error!

Author: bfavaretto, 2015-07-15

1 answers

Because it is possible to store constants in a case-insensitive way see in the documentation link

If set to TRUE, The constant will be defined case-insensitive. The default behavior is case-sensitive; i.e. CONSTANT and Constant represent different values.

Translation: if set to TRUE, the constant is set to case-insensitive. The default behavior is case-sensitive; i.e. constant and constant represent different values.

Notes: Case-insensitive constants are stored as lower-case.

Translation: case-insensitive constants are stored in low box.

Then it is possible that:

__FILE__; 

__file__;

__fiLE__;

Have the same value

Constants creation command (one of them is possible to create constants with the word const).

define ('CONSTANTE' , 12, true);
define ('CONSTANTe' , 12);
 6
Author: Ricardo, 2015-07-15 15:06:18