I can remember being told that having an if statement like if(10 == $myVariable)
is a bad practice. However, why is this a bad practice and what is its name? (I can vaguely remember that it has a specific name).
its good practice because of accidental typos
if (10 = $myVariable)
will not compile where as
if ($myVariable = 10)
will and make the if statement true, and also set $myVariable to 10
is a fairly easy to make, and hard to spot error.
http://en.wikipedia.org/wiki/Yoda_conditions
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With