Why PHP constants declared as case insensitive can be reassigned -


lately found bug in huge system i'm working on caused behaviour:

consider this:

define('test',10);  echo test; // prints 10  define('test',20); // error -> assigned. 

but if declare insensitive:

define('test',10,true);  echo test; // prints 10  define('test',20); // no error ????  echo test; //prints 20 

i understand differences between cs , ci , realise i'm creating new constant in second definition. don't understand why possible?

isn't violation of constant concept? behaviour has applications or php weird thing...

because first constant (which saved case-insensitive) saved in lowercase can read in manual:

note: case-insensitive constants stored lower-case.

means since case-insensitive variants of lower , upper case test, != test in uppercase corresponding value 10. if test case-sensitive means every letter in uppercase constant value 20.

e.g.

test -> 10 test -> 10 test -> 10 test -> 20 

and "special case" test if use before define case-sensitive constant still pointing constant value 10.


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -