#20695 [Opn->Fbk]: substr does not always return a string

From: Date: Thu, 28 Nov 2002 10:49:32 +0000
Subject: #20695 [Opn->Fbk]: substr does not always return a string
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-26054@lists.php.net to get a copy of this message
ID: 20695 Updated by: jan@php.net Reported By: RNova@gmx.net -Status: Open +Status: Feedback Bug Type: Feature/Change Request Operating System: Windows 98 PHP Version: 4.2.3 New Comment: Please try using this CVS snapshot: http://snaps.php.net/php4-latest.tar.gz For Windows: http://snaps.php.net/win32/php4-win32-latest.zip jan@dahlia ~> php bug_20695.php 1<BR> substr("A",0,1):1<BR> substr("A",0,0):1<BR> substr("A",1,1):<BR> substr("A",1,0):<BR> jan@dahlia ~> php -v PHP 4.4.0-dev (cli) works fine here Previous Comments: ------------------------------------------------------------------------ [2002-11-28 04:45:55] RNova@gmx.net substr($s,$n,$m) is supposed to always return a string (at least if $s is a string and $n and $m are integers). However: is_string(substr($s,strlen($s),$m)) returns false, so substr did not return a string. Example: echo is_string("")."<BR>\n"; echo "substr(\"A\",0,1):".is_string(substr("A",0,1))."<BR>\n"; echo "substr(\"A\",0,0):".is_string(substr("A",0,0))."<BR>\n"; echo "substr(\"A\",1,1):".is_string(substr("A",1,1))."<BR>\n"; echo "substr(\"A\",1,0):".is_string(substr("A",1,0))."<BR>\n"; ------------------------------------------------------------------------ [2002-11-28 04:40:53] RNova@gmx.net substr($s,$n,$m) is supposed to always return a string (at least if $s is a string and $n and $m are integers). However: is_string(substr($s,strlen($s),$m)) returns false, so substr did not return a string. Example: $s="<AB attr = \n\"value\" >"; echo is_string("")."<BR>\n"; echo "substr(\"A\",0,1):".is_string(substr("A",0,1))."<BR>\n"; echo "substr(\"A\",0,0):".is_string(substr("A",0,0))."<BR>\n"; echo "substr(\"A\",1,1):".is_string(substr("A",1,1))."<BR>\n"; echo "substr(\"A\",1,0):".is_string(substr("A",1,0))."<BR>\n"; ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=20695&edit=1

« previous php.bugs (#26054) next »