PHP and comparing string with numbers.

On a comparisons like if( $string == 0) the results are not trustworthy. You should use if( $string === 0) see this :

https://bugs.php.net/bug.php?id=54547.

I actually found this when doing a comparison like if( $string == “string” ). When $string is a numeric string it is cast to integer and generates a wrong false when $string = “0″.

Leave a Reply