From:             
Operating system: Windows 7
PHP version:      5.3.6
Package:          Output Control
Bug Type:         Bug
Bug description:substr return is fail

Description:
------------
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:
---------------
$x=1;
while ($x<=strlen("hello"))
{
$xx=$x-1;
echo substr("hello",$xx,$x);
$x++;
}
echo "<br/>";

$x=1;
while ($x<=strlen("hello"))
{
$xx=$x-1;
echo $xx." ";
echo $x." ";
echo substr("hello",$xx,$x);
echo "<br/>";
$x++;
}

Expected result:
----------------
i expect a result saying:

hello
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:

hellloloo
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?

-- 
Edit bug report at https://bugs.php.net/bug.php?id=55180&edit=1
-- 
Try a snapshot (PHP 5.2):            
https://bugs.php.net/fix.php?id=55180&r=trysnapshot52
Try a snapshot (PHP 5.3):            
https://bugs.php.net/fix.php?id=55180&r=trysnapshot53
Try a snapshot (trunk):              
https://bugs.php.net/fix.php?id=55180&r=trysnapshottrunk
Fixed in SVN:                        
https://bugs.php.net/fix.php?id=55180&r=fixed
Fixed in SVN and need be documented: 
https://bugs.php.net/fix.php?id=55180&r=needdocs
Fixed in release:                    
https://bugs.php.net/fix.php?id=55180&r=alreadyfixed
Need backtrace:                      
https://bugs.php.net/fix.php?id=55180&r=needtrace
Need Reproduce Script:               
https://bugs.php.net/fix.php?id=55180&r=needscript
Try newer version:                   
https://bugs.php.net/fix.php?id=55180&r=oldversion
Not developer issue:                 
https://bugs.php.net/fix.php?id=55180&r=support
Expected behavior:                   
https://bugs.php.net/fix.php?id=55180&r=notwrong
Not enough info:                     
https://bugs.php.net/fix.php?id=55180&r=notenoughinfo
Submitted twice:                     
https://bugs.php.net/fix.php?id=55180&r=submittedtwice
register_globals:                    
https://bugs.php.net/fix.php?id=55180&r=globals
PHP 4 support discontinued:          
https://bugs.php.net/fix.php?id=55180&r=php4
Daylight Savings:                    https://bugs.php.net/fix.php?id=55180&r=dst
IIS Stability:                       
https://bugs.php.net/fix.php?id=55180&r=isapi
Install GNU Sed:                     
https://bugs.php.net/fix.php?id=55180&r=gnused
Floating point limitations:          
https://bugs.php.net/fix.php?id=55180&r=float
No Zend Extensions:                  
https://bugs.php.net/fix.php?id=55180&r=nozend
MySQL Configuration Error:           
https://bugs.php.net/fix.php?id=55180&r=mysqlcfg
Try a snapshot (PHP 5.4):            
https://bugs.php.net/fix.php?id=55180&r=trysnapshot54

Reply via email to