From: technique at ircf dot fr Operating system: Linux Ubuntu PHP version: 5.2CVS-2008-01-14 (snap) PHP Bug Type: Scripting Engine problem Bug description: Cast problem with the equal operator (==)
Description: ------------ I have noticed that the equal operator will systematically try to cast expressions as integers, even when it is useless. This may cause problems like this (see the code below). Wouldn't be better to cast only one operand ONLY if the two operands are not of the same type ? For example : "1" == 1 , would cast the right operand (1) as a string and then compare it with the first "123" == "456", would not cast any operand because they already have the same type I know that this issue can be solved using the identity operator (===) but I find weird that "001" == "0001" returns true, or am I missing something ? Reproduce code: --------------- <?php if ("0001" == "000001"){ echo "Impossible !!!"; } ?> Expected result: ---------------- Nothing Actual result: -------------- Impossible !!! -- Edit bug report at http://bugs.php.net/?id=43839&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=43839&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=43839&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=43839&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=43839&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=43839&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=43839&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=43839&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=43839&r=needscript Try newer version: http://bugs.php.net/fix.php?id=43839&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=43839&r=support Expected behavior: http://bugs.php.net/fix.php?id=43839&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=43839&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=43839&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=43839&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=43839&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=43839&r=dst IIS Stability: http://bugs.php.net/fix.php?id=43839&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=43839&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=43839&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=43839&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=43839&r=mysqlcfg