|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2013-04-11 23:23 UTC] rstoll at tutteli dot ch
Description:
------------
It is possible to redefine NULL (however, not null). No one probably does that but it should not be possible. Maybe there are more of this kind of errors.
Test script:
---------------
var_dump(null); // null
var_dump(NULL); // null
define("NULL","hello world");
var_dump(null); // null
var_dump(NULL); // hello world
define("null","hello world"); //Notice: Constant null already defined
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Dec 03 23:00:01 2025 UTC |
The same issue applies to TRUE and FALSE. Example: define('TRUE', FALSE); define('FALSE', TRUE); var_dump(TRUE); var_dump(FALSE);Some more information about the define statement. I can also use define for things like that: define("1",0); define("if","else"); It doesn't have any influence on the code, if one writes 1 or if after the define then 1 is still an int and if still the keyword if, but it should not be possible in my opinion.I've just noticed somene's code on 3v4l: a lowercase versions may be redefined too if they're used in namespace. --------------------------------- namespace ns; define('ns\\true', 'blarg1'); define('ns\\false', 'blarg2'); define('ns\\null', 'blarg3'); var_dump(true, false, null); --------------------------------- This also works in PHP run from Apache and `php -f` (tested in 5.4.14 on Arch64). To make things funnier: --------------------------------- define('int', 123); var_dump(int + int); ---------------------------------