Skip to content

Latest commit

 

History

History
33 lines (27 loc) · 649 Bytes

change_boolean_constants.md

File metadata and controls

33 lines (27 loc) · 649 Bytes

Change boolean constants TRUE/FALSE (within a namespace)

NOTE: This has been fixed in PHP-7

Because TRUE and FALSE are constants of the root namespace you can define your own constants within another namespace.

Example:

(http://3v4l.org/hq7Jj)

namespace Foo;
define('Foo\\true', \false);
define('Foo\\false', \true);

var_dump(array(
    'true'  => true,
    'false' => false,
    '1===1' => 1===1,
    '1!==1' => 1!==1,
));
array(4) {
    ["true"]  => bool(false),
    ["false"] => bool(true),
    ["1===1"] => bool(true),
    |"1!==1"] => bool(false)
}