|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2009-11-16 01:44 UTC] goatlabs at gmail dot com
Description:
------------
define() constants can be modified if originally defined case-sensitive
Reproduce code:
---------------
define('TEST', 'foo', true);
var_dump(TEST);
define('TEST', 'bar');
var_dump(TEST);
Expected result:
----------------
string(3) "foo"
string(3) "foo"
Actual result:
--------------
string(3) "foo"
string(3) "bar"
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Dec 04 23:00:01 2025 UTC |
From manual notes: A note on redefining: Constants can't be redefined: $ php -r "define('A', 1); var_dump('A'); define('A', 2); var_dump('A');"; string(1) "A" PHP Notice: Constant A already defined in Command line code on line 1 string(1) "A" But using the case insensitive setting shows that the internal representation is lower case: $ php -r "define('A', 1, true); var_dump('A'); define('A', 2); var_dump('A');"; string(1) "A" string(1) "A" Note the lower case 'a' in the second define() here: $ php -r "define('A', 1, true); var_dump('A'); define('a', 2); var_dump('A');"; string(1) "A" PHP Notice: Constant a already defined in Command line code on line 1 string(1) "A" (Short version: Yes, but no)