I just reduced the crazy mistake to what's in the title of this question. I am sure there is a perfectly reasonable explanation for why Php considers 0 == '%' (or any other special character, I think). I thought it would be nice to get this explanation on StackOverflow!
Using '===' (for an exact, literal comparison - the values must be of the same type and also equal) instead of '==' solves this problem. With '==', he is trying to distinguish '%' from a number, and 0 is the best he can do.
, 0.
, , , , strcmp(). , , , int. , , , strcmp() .
php . ( ), . http://www.php.net/manual/en/types.comparisons.php
"%" , (0), , , 0 == '%'
;-) ,