Recently, I came across a code like this:
if (0 === $something) { }
Is there any difference between the code above with:
if ($something === 0) { }
Recently, I came across a code like this:
if (0 === $something) { }
Is there any difference between the code above with:
if ($something === 0) { }
Actually there is no difference in both performance wise or in functional perspective. I can say it's a personal choice of coding style often called that as Yoda Style
In programming jargon, Yoda conditions (also called Yoda notation) is a programming style where the two parts of an expression are reversed in a conditional statement.
I prefer the later way as the first way kills the readability of code (at least for me)
No, there is absolutely no difference between the two as the if condition will check for equality between both sides.