From: kkitts at clearviewcatv dot net Operating system: Windows XP SP2 PHP version: 5.2.4 PHP Bug Type: Strings related Bug description: possible stripos bug...
Description: ------------ This may or may not be a bug, but it is very inconvenient. stripos returns the location of string1 within string2. If it doesn't find string1 within string2, it returns false. This works well, unless string1 is found at position 0 (the first character of the string). In this case, it returns the position of string1 in string2, which happens to be 0. This is also the value of the "FALSE" definition. So, when I have code like below, the echo statement never gets executed because the if() function thinks 0 == FALSE. I'm still trying to think of a manual workaround. Possible fix: rewrite stripos to have optional 4th parameter specifying an alternate return value if string1 isn't found in string2 (such as stripos($str, "pineapple", 0, -1), which would return -1 instead of FALSE). Reproduce code: --------------- $str = "pineapple"; if(strripos($str, "pineapple", 0)) { echo "Comments cannot contain \"pineapple\".<br/>"; } Expected result: ---------------- Comments cannot contain "pineapple". Actual result: -------------- (nothing) -- Edit bug report at http://bugs.php.net/?id=43218&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=43218&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=43218&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=43218&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=43218&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=43218&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=43218&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=43218&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=43218&r=needscript Try newer version: http://bugs.php.net/fix.php?id=43218&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=43218&r=support Expected behavior: http://bugs.php.net/fix.php?id=43218&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=43218&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=43218&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=43218&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=43218&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=43218&r=dst IIS Stability: http://bugs.php.net/fix.php?id=43218&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=43218&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=43218&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=43218&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=43218&r=mysqlcfg