This highly depends on the language used!
== is implemented as a method in an object oriented language then the construct
if ($variable == "") could lead to an exception because the object (
$variable) might not be initialized or even
If you reverse the expression (
if ("" == $variable)) then you can be sure that the object acted on (
"" is always initialized and never
As an example in Java (where the method is called
can cause a
NullPointerException because the object
string may be
cannot lead to a
NullPointerException as the object
"" is never
== is not a method of an object then it does not matter which order is used.
I think that many programmers with such a background use the expression
if ("" == $variable) because they are more familiar with it.