When I was learning PHP, I read somewhere that you should always use the upper case versions of booleans, TRUE
and FALSE
, because the "normal" lowercase versions, true
and false
, weren't "safe" to use. This applies to NULL
and null
as well.
It's now been many years, and every PHP script I've written uses the uppercase version. Now, though, I am questioning that, as I have seen plenty of PHP written with the lowercase version (i.e. Zend Framework).
Is/Was there ever a reason to use the uppercase version, or is it perfectly OK to use the lowercase?
The official PHP manual says:
To specify a bool literal, use the constants true or false. Both are case-insensitive.
So yeah, true === TRUE
and false === FALSE
.
Personally, however, I prefer TRUE
over true
and FALSE
over false
for readability reasons. It's the same reason for my preference on using OR
over or
or ||
, and on using AND
over and
or &&
.
The PSR-2 standard requires true
, false
and null
to be in lower case.