Can someone, for the love of all things natural, please explain why this is happening?
$code = 0;
echo $code == 'item_low_stock' ? 'equal' : 'not equal';
// RESULT: "equal"
???
A line of code in my app just suddenly stopped working properly, I haven't edited anything around it, changed my php version, anything. When the $code variable contains 0, it is passing as true when I compare it to the string 'item_low_stock'.
I can post the original block of code, but I boiled it down to this comparison and this is what I found.
Halp.
EDIT: PHP version is 5.3.10.
===, which will also ensure that the types being compared are the same. Thus, if$codeis not 'item_low_stock' or not a string, the comparison works as expected.