From: emil at nachev dot eu Operating system: Debian GNU/Linux PHP version: 5.2.10 PHP Bug Type: Unknown/Other Function Bug description: strpos() does not match newlines at the end of $needle
Description: ------------ If $needle is a string that ends with a newline, strpos() does not find the string in the $haystack, although it is there. Reproduce code: --------------- $text = <<<TEXT This is just some text, with something in the middle that has newlines around it. TEXT; // The text contains both needles below: $result = strpos($text, "\nsomething in the middle"); echo 'This works: '; var_dump($result); echo "\n<br>\n"; $buggy_result = strpos($text, "something in the middle\n"); echo 'This does not: '; var_dump($buggy_result); Expected result: ---------------- I expect matching for both "\nsomething in the middle" and "something in the middle\n" to return an integer. Matching for "something in the middle", without the newline, returns int(33) (as expected). Actual result: -------------- I get boolean false when matching for a string with "\n" at the end of $needle: This works: int(32) This does not: bool(false) -- Edit bug report at http://bugs.php.net/?id=49208&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=49208&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=49208&r=trysnapshot53 Try a snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=49208&r=trysnapshot60 Fixed in SVN: http://bugs.php.net/fix.php?id=49208&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=49208&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=49208&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=49208&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=49208&r=needscript Try newer version: http://bugs.php.net/fix.php?id=49208&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=49208&r=support Expected behavior: http://bugs.php.net/fix.php?id=49208&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=49208&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=49208&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=49208&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=49208&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=49208&r=dst IIS Stability: http://bugs.php.net/fix.php?id=49208&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=49208&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=49208&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=49208&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=49208&r=mysqlcfg