I wanted to comment on the comment, but I thought I’d just post it here.
That’s a very good coding practice!
I tend to forget it constantly - mainly due to the fact that it just feels very unnatural - but it’s awesome because it is not possible to accidentally assign something.
This would pass but accidentally change the variable:
if($cache = false)
This wouldn’t:
if(false = $cache)
So, it’s a good practice. IMO.
It’s easier to shoot yourself if you don’t use this inverse test technique, if you use non-strict comparison operators, like ‘==’.
Late at night, it’s hard to spot the difference between ‘==’ and ‘=’ …
The technique above is a better-safe-than-sorry approach.
You could at least PM my, jacmoe, that you are opening discussion upon my comment! You are a bad boy!
No, it’s not! All you need is a good software for editing your PHP files. For example using NetBeans (wonderful, but a bit slow!) you will always get green underline in such situations. In this particular, with comment saying “Possible accidental assignment. Assignments in conditions should be avoided”. Brilliant!