From:             ravacholp at hotmail dot com
Operating system: windows 2000
PHP version:      4.3.2
PHP Bug Type:     Strings related
Bug description:  substr returns "0" for any offset on the string "0"

Description:
------------
substr() returns "0" for any offset on the string "0" using the length 1.

This causes an infinite loop if you are checking for leading zeros in your
string using substr().

Reproduce code:
---------------
$str = "0";

print (substr($str, 0, 1) == "0");
print (substr($str, 1, 1) == "0");

print (substr($str, 5, 1) == "0");

// only the first line should evaluate to true

Expected result:
----------------
111


-- 
Edit bug report at http://bugs.php.net/?id=26292&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=26292&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=26292&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=26292&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=26292&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=26292&r=needtrace
Try newer version:          http://bugs.php.net/fix.php?id=26292&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=26292&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=26292&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=26292&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=26292&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=26292&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=26292&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=26292&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=26292&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=26292&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=26292&r=float

Reply via email to