That is called Yoda notation.
As Sanjog mentioned, it is used to avoid making the mistake of making an assignment instead of verifying an equality.
The main problem though is that this method is not a great practice in terms of making nice code.
The book "The Art of Readable Code" has an interesting comment on that:
In some languages (including C and C++, but not Java), it’s legal to put an assignment inside an if condition:
if (obj = NULL) ...
Most likely this is a bug, and the programmer actually meant:
if (obj == NULL) ...
To prevent bugs like this, many programmers switch the order of arguments:
if (NULL == obj) ...
This way, if ==
is accidentally written as =
, the expression if (NULL = obj)
won’t even compile. Unfortunately, switching the order makes the code a bit unnatural to read. (As Yoda would say, “Not if anything to say about it I have.”) Thankfully, modern compilers warn against code like if (obj = NULL)
, so “Yoda Notation” is becoming a thing of the past.
Unfortunately for you, assignments inside if's are not illegal in PHP.