[PHP] This is happening why?
Run this code: ? if( 0 == 'NULL' ) { echo 'NULL' == 0br; } else { echo 'NULL' != 0br; } ? Is this just a case of PHP converting variable types for comparison? thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] This is happening why?
Yeah.. you're comparing a string, 'NULL' with an integer 0. You're not comparing NULL with anything, you're comparing a string that contains the word 'NULL'. You can use === to do an exact comparison without conversion. echo intval('NULL'); intval('NULL') === 0 = = = Original message = = = Run this code: ? if( 0 == 'NULL' ) echo 'NULL' == 0br; else echo 'NULL' != 0br; ? Is this just a case of PHP converting variable types for comparison? thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php ___ Sent by ePrompter, the premier email notification software. Free download at http://www.ePrompter.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] This is happening why?
[snip] ? if( 0 == 'NULL' ) { echo 'NULL' == 0br; } else { echo 'NULL' != 0br; } ? [/snip] Interesting, to be sure. I even flipped the test if('NULL' == 0) Of course, once I made 0 a string '0' the test evaluated FALSE. So 0 (integer) is TRUE and 'NULL' is TRUE, which means that you asked if(TRUE == TRUE), which is, of course, TRUE. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php