[PHP] var_dump( (0 == 'heading') ) == TRUE ?!

2010-05-14 Thread Daevid Vincent
Can someone explain why an integer 0 compared to a string evaluates to boolean true?? var_dump( (0 == 'heading') ); Yet, var_dump( (1 == 'heading') ); Is FALSE. WTF? I would expect the 0 one to be FALSE too. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:

Re: [PHP] var_dump( (0 == 'heading') ) == TRUE ?!

2010-05-14 Thread James Colannino
I'm pretty sure this is the right answer. If not, someone please correct me. PHP will compare the 0 against the integer represented by the string. So, for example, 0 == 0 would test true. 0 == 1 would test false. However, 'heading' doesn't represent a valid integer, so it appears on the right

Re: [PHP] var_dump( (0 == 'heading') ) == TRUE ?!

2010-05-14 Thread richard gray
On 15/05/2010 03:19, Daevid Vincent wrote: Can someone explain why an integer 0 compared to a string evaluates to boolean true?? var_dump( (0 == 'heading') ); Yet, var_dump( (1 == 'heading') ); Is FALSE. WTF? I would expect the 0 one to be FALSE too.

Re: [PHP] var_dump( (0 == 'heading') ) == TRUE ?!

2010-05-14 Thread kranthi
== operator type casts the string to integer before comparing so the comparison boils down to 0 == 0 which is true these rules also apply to the switch statement http://php.net/manual/en/language.operators.comparison.php but with === the typecasting does no occur -- PHP General Mailing List