Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

false / FALSE — any difference?

Tags:

php

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.

like image 206
n00b Avatar asked Jun 22 '10 13:06

n00b


People also ask

What is difference between false and false?

FALSE is not defined in the standard. Only false is. true and false are called "Boolean literals", and are keywords in C++. FALSE is sometimes defined as a macro.

What is false && false?

If the left side of the expression is "falsey", the expression will return the left side. If the left side of the expression is "truthy", the expression will return the right side. That's it. So in false && false , the left side is "falsey", so the expression returns the left side, false .

Is false == false true?

In Math a = b = c mean all a = b , b = c and a = c . So True is False == False means True == False and False == False and True == False , which is False . For boolean constants, is is equivalent to == . Actually, a is b == c only means (a is b) and (b == c) : a and c are not compared.

What does false or false evaluate to?

TRUE (say: not true) to evaluate to FALSE and ! FALSE (say: not false) to evaluate to TRUE. Try using the NOT operator and the equals operator to find the opposite of whether 5 is equal to 7.


2 Answers

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

like image 165
NibblyPig Avatar answered Oct 01 '22 15:10

NibblyPig


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.

like image 21
Reece Ward Avatar answered Oct 01 '22 15:10

Reece Ward