Reputation: 10403
Is there a difference between true
and TRUE
or false
and FALSE
in PHP?
Upvotes: 7
Views: 2762
Reputation: 403
If you intend to use JSON then the standard RFC7159 says :
The literal names MUST be lowercase. No other literal names are allowed.
And from Php 5.6 :
json_decode() now rejects non-lowercase variants of the JSON literals true, false and null at all times, as per the JSON specification
And according to PSR-2 standard :
PHP keywords MUST be in lower case.
The PHP constants true, false, and null MUST be in lower case.
Ps.: I could not post link to the RFC7159 because of SO limitations.
Upvotes: 5
Reputation: 145482
Constants are case-sensitive per default. But for symmetry to the other identifier namespaces, they can be defined case-insensitively:
define("mixedCASE", 123, TRUE);
print MiXeDcAsE;
And that's just how TRUE
and FALSE
were pre-declared. (They aren't parser/language builtins.)
Upvotes: 2
Reputation: 1089
Nope, the PHP Parser isn't very fussy when it comes to TRUE, true and FALSE, false
Upvotes: 1
Reputation: 17434
http://php.net/manual/en/language.types.boolean.php
To specify a boolean literal, use the keywords TRUE or FALSE. Both are case-insensitive.
Upvotes: 0