6

Is there a difference between true and TRUE or false and FALSE in PHP?

Roman
  • 10,309
  • 17
  • 66
  • 101
  • 2
    Because you could have found this out yourself in five seconds with Google. – Interrobang Dec 22 '11 at 03:11
  • 1
    Then what's up with this discussion: http://stackoverflow.com/questions/2013848/uppercase-booleans-vs-lowercase-in-php if all there is to this can be googled in 5 mins? – frnhr Jun 19 '13 at 02:37

4 Answers4

4

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.

Community
  • 1
  • 1
Mandrake
  • 393
  • 3
  • 4
2

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.)

mario
  • 144,265
  • 20
  • 237
  • 291
1

Nope, the PHP Parser isn't very fussy when it comes to TRUE, true and FALSE, false

Kodlee Yin
  • 1,089
  • 5
  • 10
0

http://php.net/manual/en/language.types.boolean.php

To specify a boolean literal, use the keywords TRUE or FALSE. Both are case-insensitive.

Interrobang
  • 16,984
  • 3
  • 55
  • 63