Edit report at https://bugs.php.net/bug.php?id=60672&edit=1
ID: 60672 Updated by: fel...@php.net Reported by: danillo dot paiva dot toledo at gmail dot com Summary: ELSEIF/ELSE IF doesn't work -Status: Open +Status: Bogus Type: Bug Package: Variables related Operating System: Windows XP PHP Version: Irrelevant Block user comment: N Private report: N 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 Previous Comments: ------------------------------------------------------------------------ [2012-01-06 16:22:00] anon at anon dot anon This occurs because 0 == "some_string" is true, and 0 == false is true. See: http://php.net/manual/en/types.comparisons.php Use === instead of == (and !== instead of !=) to stop type conversion in comparisons. ------------------------------------------------------------------------ [2012-01-06 16:14:32] danillo dot paiva dot toledo at gmail dot com $x = 0; $y = "some_string"; if( $x == 2 ) { echo "X = 2.<br/>"; echo "Inner first IF"; } elseif ( $x == $y ) { echo "We are at the elseif condition."; } else { echo "I don't know what's X value."; } 1st - That's my first time using bug report on php.net. 2nd - I'm brazilia(sorry my english). 3rd - I don't know I'm using the correct channel to report this. I used WAMPServer2.1 to discover this bug. The current PHP version used on used WAMPServer2.1 is 5.3.5. This prints "We are at the elseif condition.". The same happens if the $y value is false. ------------------------------------------------------------------------ [2012-01-06 16:11:19] danillo dot paiva dot toledo at gmail dot com Description: ------------ $x = 0; $y = "some_string"; if( $x == 2 ) { echo "X = 2.<br/>"; echo "Inner first IF"; } elseif ( $x == $y ) { echo "We are at the elseif condition."; } else { echo "I don't know what's X value."; } Test script: --------------- 1st - That's my first time using bug report on php.net. 2nd - I'm brazilia(sorry my english). 3rd - I don't know I'm using the correct channel to report this. I used WAMPServer2.1 to discover this bug. The current PHP version used on used WAMPServer2.1 is 5.3.5. This prints "We are at the elseif condition.". The same happens if the $y value is false. Expected result: ---------------- Expected result would be: "I don't know what's X value.". Actual result: -------------- Actual result would be: "I don't know what's X value.". ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=60672&edit=1