What is the difference between the 2 statements:
if (false === $variable) {
//do something
}
and
if ($variable === false) {
//do something
}
I personally use the second style but often run into code in frameworks that i use which always seem to use the first style.
Is there a difference ( i suspect it is some legacy thing to do with types) or is this simply a coding habit (it must be rooted in something though??)
If not, what is the reasoning behind the first style given that the logic is actually backwards.
if ($foo = false)(note:=instead of==) is a typical typo that leads to hard to debug problems. For that reason, some people preferfalse == $foo, since the runtime will throw an error when you try to assign something tofalse.Other than that there’s no difference.