I'm wondering, in PHP, I've seen people use both these cases:
if($var === TRUE)
if($var === true)
is there an actual difference between them or a coding standard/format to be used in boolean value?
There's no difference at all. From the docs:
To specify a boolean literal, use the keywords TRUE or FALSE. Both are case-insensitive.
According to PSR-2, as stated by both Laxus and Paul Bain in their comments, the standard is to write them in lower case.
lowercase is generally considered a good practice, see the coloration of the lowercase on stackoverflow :)
And not related, but you should always use true first in the condition true === $var
, this is a good practice to avoid sneaky bugs when mistyping the condition, eg : $var = true
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With