|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #55180 substr return is fail
Submitted: 2011-07-11 07:52 UTC Modified: 2011-07-11 12:09 UTC
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: jonasvdegn at hotmail dot com Assigned:
Status: Not a bug Package: Strings related
PHP Version: 5.3.6 OS: Windows 7
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: jonasvdegn at hotmail dot com
New email:
PHP Version: OS:


 [2011-07-11 07:52 UTC] jonasvdegn at hotmail dot com
the substr(string,from,to) failed and return something i find strange, and never seen it before..

my version is also 5.3.5 but i chose 5.3.6 because the 5.3.5 is not there.

Test script:
while ($x<=strlen("hello"))
echo substr("hello",$xx,$x);
echo "<br/>";

while ($x<=strlen("hello"))
echo $xx." ";
echo $x." ";
echo substr("hello",$xx,$x);
echo "<br/>";

Expected result:
i expect a result saying:

0 1 h
1 2 e
2 3 l
3 4 l
4 5 o

like in substr("hello",0,1) substr("hello",1,2) and continue like that.

Actual result:
the actual result is:

0 1 h
1 2 el
2 3 llo
3 4 lo
4 5 o

like substr("hello",1,2) is "el" how can that be?
and  substr("hello",2,3) is "llo" and how can that be too?


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2011-07-11 12:09 UTC]
-Status: Open +Status: Bogus -Package: Output Control +Package: Strings related
 [2011-07-11 12:09 UTC]
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

The third parameter for substr() is the number of characters to return, not the 
end position.
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Mon Oct 26 05:01:24 2020 UTC