#17997 [Opn->Ver]: got wanning when combing switch & reference
| From: | iliaa@php.net | Date: | Wed, 06 Nov 2002 04:02:18 +0000 |
| Subject: | #17997 [Opn->Ver]: got wanning when combing switch & reference | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-24167@lists.php.net to get a copy of this message | ||
ID: 17997
Updated by: iliaa@php.net
Reported By: Xuefer@21cn.com
-Status: Open
+Status: Verified
Bug Type: Scripting Engine problem
Operating System: shoul be all
-PHP Version: 4.2.1
+PHP Version: 4.3.0-dev
Previous Comments:
------------------------------------------------------------------------
[2002-07-23 16:45:31] hholzgra@php.net
the error message is on the closing '}' of the switch ...
does switch re-evaluate its argument on termination?
this is scary!
------------------------------------------------------------------------
[2002-06-26 11:25:14] Xuefer@21cn.com
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 this bug report at http://bugs.php.net/?id=17997&edit=1