|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2004-07-01 20:49 UTC] mgf@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Dec 06 23:00:01 2025 UTC |
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