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 :

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