ID: 28986 Updated by: [EMAIL PROTECTED] Reported By: philipp at bind dot ch -Status: Open +Status: Bogus Bug Type: *General Issues Operating System: Linux PHP Version: Irrelevant New Comment:
Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php This is how == works (if either side is an int, the other is also converted to int before comparison). Use === if you want to take type into account as well as value. (See also http://uk.php.net/manual/en/types.comparisons.php and http://uk.php.net/manual/en/language.types.type-juggling.php) Previous Comments: ------------------------------------------------------------------------ [2004-07-01 20:26:36] philipp at bind dot ch Description: ------------ hi there! I'll past some code here to explain my problem. I dont know if it is a bug or not bug it looks like one to me! I had some real ugly problems because of this. If you have a look at the output of this code you'll see what i mean! if php commpares 0 with any string the if function tells us that this is true. I cant believe that the language should be like that so I wrote this bug-report. Reproduce code: --------------- $test_char = 'a'; $my_array = array(0, 1, '0', '1', 'a', 'b'); for($i = 0; $i < 6; $i++) { if($my_array[$i] == $test_char) echo("php's 'if' tells us that {$my_array[$i]} is the same as {$test_char}\n"); else echo("php's 'if' tells us that {$my_array[$i]} is not the same as {$test_char}\n"); } Expected result: ---------------- php's 'if' tells us that 0 is not the same as a php's 'if' tells us that 1 is not the same as a php's 'if' tells us that 0 is not the same as a php's 'if' tells us that 1 is not the same as a php's 'if' tells us that a is the same as a php's 'if' tells us that b is not the same as a Actual result: -------------- php's 'if' tells us that 0 is the same as a php's 'if' tells us that 1 is not the same as a php's 'if' tells us that 0 is not the same as a php's 'if' tells us that 1 is not the same as a php's 'if' tells us that a is the same as a php's 'if' tells us that b is not the same as a ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=28986&edit=1