From:             bugs dot php dot net at kreidenweis dot com
Operating system: Linux
PHP version:      5.2.2
PHP Bug Type:     Strings related
Bug description:  substr() undocumented behavior change from 5.2.1 to 5.2.2

Description:
------------
substr() handled a negative $start parameter with an absolute value larger
than the $string's length gracefully and sensibly up to PHP 5.2.1

In 5.2.2 this behavior changed without that being mentioned in the
documentation.

IMHO it probably has something to do with the fix for
http://bugs.php.net/bug.php?id=40754

I guess (and hope ;) the behavior change wasn't intended. But if indeed
so, please put a warning in the documentation.

Reproduce code:
---------------
var_dump(substr('abc', -4));

Expected result:
----------------
string(3) "abc"

(up to PHP 5.2.1 this is what happens)

Actual result:
--------------
bool(false)

(output by PHP 5.2.2)

-- 
Edit bug report at http://bugs.php.net/?id=41375&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=41375&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=41375&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=41375&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=41375&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=41375&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=41375&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=41375&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=41375&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=41375&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=41375&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=41375&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=41375&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=41375&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=41375&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=41375&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=41375&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=41375&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=41375&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=41375&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=41375&r=mysqlcfg

Reply via email to