#39278 [NEW]: strpos($needle, $integer) returns 0 for certain values of $integer

From: Date: Fri, 27 Oct 2006 11:13:08 +0000
Subject: #39278 [NEW]: strpos($needle, $integer) returns 0 for certain values of $integer
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-104067@lists.php.net to get a copy of this message
From: matt at raines dot me dot uk Operating system: GNU/Linux 2.4.27 PHP version: 5.1.6 PHP Bug Type: Strings related Bug description: strpos($needle, $integer) returns 0 for certain values of $integer Description: ------------ Searching for a string in an integer using strpos() returns integer 0 if (integer % 256) is the lowest ASCII value of any character in the search string, or the highest ASCII value of any character minus 256. Otherwise it returns boolean false as expected. Reproduce code: --------------- var_dump(strpos("A", 65)); var_dump(strpos("A", 66)); var_dump(strpos("B", 65)); var_dump(strpos("B", 66)); Expected result: ---------------- bool(false) bool(false) bool(false) bool(false) Actual result: -------------- int(0) bool(false) bool(false) int(0) -- Edit bug report at http://bugs.php.net/?id=39278&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=39278&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=39278&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=39278&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=39278&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=39278&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=39278&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=39278&r=needscript Try newer version: http://bugs.php.net/fix.php?id=39278&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=39278&r=support Expected behavior: http://bugs.php.net/fix.php?id=39278&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=39278&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=39278&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=39278&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=39278&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=39278&r=dst IIS Stability: http://bugs.php.net/fix.php?id=39278&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=39278&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=39278&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=39278&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=39278&r=mysqlcfg

« previous php.bugs (#104067) next »