#17997 [Ver->Csd]: Warning when switch & reference are combined
| From: | zeev@php.net | Date: | Tue, 07 Oct 2003 16:01:44 +0000 |
| Subject: | #17997 [Ver->Csd]: Warning when switch & reference are combined | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-48654@lists.php.net to get a copy of this message | ||
ID: 17997
Updated by: zeev@php.net
Reported By: Xuefer at 21cn dot com
-Status: Verified
+Status: Closed
Bug Type: Scripting Engine problem
Operating System: All
PHP Version: 4CVS, 5CVS
New Comment:
This bug has been fixed in CVS.
In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at http://snaps.php.net/.
In case this was a documentation problem, the fix will show up soon at
http://www.php.net/manual/.
In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites in short time.
Thank you for the report, and for helping us make PHP better.
Fixed
Previous Comments:
------------------------------------------------------------------------
[2003-08-10 18:12:54] helly@php.net
Yes it refetches the variable passed to switch() to check whether it
must be freed or not.
------------------------------------------------------------------------
[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 at 21cn dot 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