Bug #17997: got wanning when combing switch & reference
| From: | Xuefer at 21cn dot com | Date: | Wed, 26 Jun 2002 15:25:14 +0000 |
| Subject: | Bug #17997: got wanning when combing switch & reference | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-12134@lists.php.net to get a copy of this message | ||
From: Xuefer@21cn.com
Operating system: shoul be all
PHP version: 4.2.1
PHP Bug Type: Scripting Engine problem
Bug description: got wanning when combing switch & reference
let the sample code say the problem
<?
error_reporting(E_ALL);
$str1 = '.........$...';
$str = &$str1;
$l = strlen($str);
for ($i = 0; $i < $l; $i ++)
{
switch ($str{$i})
{
case '$':
$str = '123'; // change string
$i = -1; // set to -1, for next loop to be 0
$l = strlen($str); // u know what this do
break;
default:
echo $str{$i};
}
}
?>
-----------
result:
-----------
.........
Notice: Uninitialized string offset: 9 in
d:\myfile\wwwroot\our-sky.com\test.php on line 19
123
how ever, if i change
$str = '123';
to:
$s = '123';
$str = &$s;
no wanning
--
Edit bug report at http://bugs.php.net/?id=17997&edit=1
--
Fixed in CVS: http://bugs.php.net/fix.php?id=17997&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=17997&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=17997&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=17997&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=17997&r=support
Expected behavior: http://bugs.php.net/fix.php?id=17997&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=17997&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=17997&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=17997&r=globals