Home » Php » php – false / FALSE — any difference?

php – false / FALSE — any difference?

Posted by: admin April 23, 2020 Leave a comment

Questions:

I noticed that some PHP frameworks use exclusively lowercase true/false and others upper.

Does it make any difference at all? I for one prefer lowercase.

How to&Answers:

No difference, some people consider FALSE to be a constant and thus use the old screaming caps notation.

Answer:

It’s been some time but because this is the first search result for the query I thought this info would be useful.

According to the PSR-2 Coding Style Guide

PHP keywords MUST be in lower case. The PHP constants true, false,
and null MUST be in lower case.

Even though you can use the screaming caps notation; if you are trying to follow these guidelines you should be doing it in lowercase. There will be no functional difference either way.

Answer:

I know I’m late to the party here, but I’ll just quote the documentation in case anybody wants an authoritative answer, as I did.

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

In fact, the example immediately following the above uses this fact:

$foo = True; // assign the value TRUE to $foo

PhP is biZarRe.