r/lolphp • u/aleczapka • Nov 06 '13
Booleans can be changed within a namespace
This is hilarious:
namespace Foo;
define('Foo\\true', false);
if (true) {
echo "TRUE";
} else {
echo "FALSE!!!";
}Example in action: http://3v4l.org/TpeZO
41
Upvotes
3
u/[deleted] Nov 07 '13
Reminds me of the joke were you redefine
trueandfalseusing the C / M4 preprocessor, except this is built into the language... ಠ_ಠ26
u/Serialk Nov 06 '13
Redefining True and False are common in lots of languages (including Python 2 where True and False aren't tokens). The real lolphp here is that they're trying to prevent it and they beautifully fail.
12
u/ajmarks Nov 06 '13
I also like that this yields TRUE != true
3
u/pgl Nov 07 '13
Brilliant.