ID:               26292
 Updated by:       [EMAIL PROTECTED]
 Reported By:      ravacholp at hotmail dot com
-Status:           Open
+Status:           Bogus
 Bug Type:         Strings related
 Operating System: windows 2000
 PHP Version:      4.3.2
 New Comment:

With a more reliable test script:

# cat t.php 
<?php
$str = "0";
var_dump(substr($str, 0, 1));
var_dump(substr($str, 1, 1));
var_dump(substr($str, 5, 1));
?>

# php t.php 
string(1) "0"
bool(false)
bool(false)

No bug here.



Previous Comments:
------------------------------------------------------------------------

[2003-11-17 17:16:07] ravacholp at hotmail dot com

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 this bug report at http://bugs.php.net/?id=26292&edit=1

Reply via email to