From: Operating system: Ubuntu PHP version: 5.2.13 Package: Strings related Bug Type: Bug Bug description:Loose comparison too loose
Description: ------------ if ("0080" == "80e0") echo "Smoking crack!"; I created a double octet coded character set. I'm using 4 hex to represent each character. I'm using a switch statement to get a token based on the value. The string "80e0" is incorrectly setting off the case "0080" statement. The strict comparison of === works as expected, but the switch uses a loose comparison. Test script: --------------- if ("0080" == "80e0") { echo "Too loose"; } else { echo "Just right"; } Expected result: ---------------- Just right Actual result: -------------- Too loose -- Edit bug report at http://bugs.php.net/bug.php?id=51795&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=51795&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=51795&r=trysnapshot53 Try a snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=51795&r=trysnapshot60 Fixed in SVN: http://bugs.php.net/fix.php?id=51795&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=51795&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=51795&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=51795&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=51795&r=needscript Try newer version: http://bugs.php.net/fix.php?id=51795&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=51795&r=support Expected behavior: http://bugs.php.net/fix.php?id=51795&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=51795&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=51795&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=51795&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=51795&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=51795&r=dst IIS Stability: http://bugs.php.net/fix.php?id=51795&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=51795&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=51795&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=51795&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=51795&r=mysqlcfg