From: relo dot san at gmail dot com Operating system: CentOS 5 PHP version: 5.2.9 PHP Bug Type: Scripting Engine problem Bug description: Unexpected return in substr function with negative start parameter
Description: ------------ >From manual: "If length is given and is positive, the string returned will contain at most length characters beginning from start (depending on the length of string). If string is less than or equal to start characters long, FALSE will be returned." This bug detected in PHP versions >= 5.2.8 Results on different versions and OS: PHP Version 5.2.5, Windows and linux: boolean: false PHP Version 5.2.8, CentOS: string(1) "1" PHP 5.2.8 (cli) (built: Feb 5 2009 21:21:13), MacOS: string(1) "1" PHP Version 5.2.9, CentOS: string(1) "1" Maby is mistake in manual and substr do not accept negative start param if string length less than start? Reproduce code: --------------- var_dump( substr( '1', -2, 1 ) ); Expected result: ---------------- boolean: false Actual result: -------------- string(1) "1" -- Edit bug report at http://bugs.php.net/?id=48269&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=48269&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=48269&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=48269&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=48269&r=fixedcvs Fixed in CVS and need be documented: http://bugs.php.net/fix.php?id=48269&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=48269&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=48269&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=48269&r=needscript Try newer version: http://bugs.php.net/fix.php?id=48269&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=48269&r=support Expected behavior: http://bugs.php.net/fix.php?id=48269&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=48269&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=48269&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=48269&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=48269&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=48269&r=dst IIS Stability: http://bugs.php.net/fix.php?id=48269&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=48269&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=48269&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=48269&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=48269&r=mysqlcfg