#43964 [NEW]: Comparison of strings containing numbers results in an incorrect response.

From: Date: Tue, 29 Jan 2008 09:25:48 +0000
Subject: #43964 [NEW]: Comparison of strings containing numbers results in an incorrect response.
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-121715@lists.php.net to get a copy of this message
From: twinge at magma dot ca Operating system: openSuse 10.3 PHP version: 5.2.5 PHP Bug Type: Strings related Bug description: Comparison of strings containing numbers results in an incorrect response. Description: ------------ If two strings containing numbers are compared using an if statement, only the first 16 bytes of the string are compared. Any bytes after the 16th byte are ignored in the comparison. Reproduce code: --------------- <?PHP $value1="12345678901234567890123456789012"; $value2="12345678901234567890123456789011"; if ($value1!=$value2){print"Not equal.<br>";} if ($value1==$value2){print"Equal.<br>";} var_dump($value1); print "<br>"; var_dump($value2); print "<br>"; ?> Expected result: ---------------- Not equal. string(32) "12345678901234567890123456789012" string(32) "12345678901234567890123456789011" Actual result: -------------- Equal. string(32) "12345678901234567890123456789012" string(32) "12345678901234567890123456789011" -- Edit bug report at http://bugs.php.net/?id=43964&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=43964&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=43964&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=43964&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=43964&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=43964&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=43964&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=43964&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=43964&r=needscript Try newer version: http://bugs.php.net/fix.php?id=43964&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=43964&r=support Expected behavior: http://bugs.php.net/fix.php?id=43964&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=43964&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=43964&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=43964&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=43964&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=43964&r=dst IIS Stability: http://bugs.php.net/fix.php?id=43964&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=43964&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=43964&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=43964&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=43964&r=mysqlcfg

« previous php.bugs (#121715) next »