What is the reason for placing a boolean or null value in front of the comparison operator?

In PHP, what is the main reason for placing either a boolean or a null value before an identical comparison operator?

false === $value; null === $value; 

It seems to me like saying this

 $value === false; 

Is this just a personal preference or is there a specific reason why people do this?

+7
source share
3 answers

This convention is to avoid the error of accidentally assigning a variable.

 $value = false; 

instead

 $value === false; 
+12
source

This is sometimes called the conditions of Iodine, there is a list of all such structures and their unofficial names.

There is no real difference between $var === false or false === $var , some people argue that it’s easier to see what is checked if bool is a left operand, others hate it ... In short, personal preference is that , what is it.

+4
source

It was supposed to be faster, but I can't rely on authority talking about it with a simple Google search. Cm:

http://forums.phpfreaks.com/topic/222939-is-there-a-difference-between-ifvar-false-and-iffalse-var/

for one opinion.

-one
source

All Articles