Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

if(0 == '%') echo "WTF, Php, why can't you compare things sanely?"

I just reduced a crazy bug to what's in the title of this question. I'm sure there's a Perfectly Reasonable Explanation for why Php thinks that 0 == '%' (or any other special character, I think). I thought it would be good to get that explanation on StackOverflow!

like image 245
dreeves Avatar asked Feb 24 '10 00:02

dreeves


1 Answers

It will do the same to any string, converting a non-number string to integer always gives 0.

like image 52
Goran Rakic Avatar answered Nov 15 '22 03:11

Goran Rakic