PHP 4.0 Bug #5052: Bug in ref-count(?) working with nested foreach() on copied var
| From: | waldschrott at kiffen dot de | Date: | Thu, 15 Jun 2000 06:26:01 +0000 |
| Subject: | PHP 4.0 Bug #5052: Bug in ref-count(?) working with nested foreach() on copied var | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-21390@lists.php.net to get a copy of this message | ||
From: waldschrott@kiffen.de
Operating system: win2000 / perhaps all
PHP version: 4.0 Latest CVS (15/06/2000)
PHP Bug Type: Feature/Change Request
Bug description: Bug in ref-count(?) working with nested foreach() on copied var
1.) Serious bug, nesting of foreach() does not work if the nested foreach() works with a copy of the
same var.
Code below results in...
"b0a0a1a2a3a4a5a6"
instead of "b0a0a1a2a3a4a5a6b1a0a2....b6a0a1a2a3a4a5a6" foreach() copies the array it uses
to use the pointer internally, why doesn´t nesting work?
That´s a bug that will definitively affect users...
$b=$a=array(0,1,2,3,4,5,6);
foreach($b AS $test) {
print 'b'.$test;
foreach ($a AS $test2) {
print 'a'.$test2; } }
2.) Once again this can be "fixed" using this strange snipplet:
$b=&$b;
Which should BTW, (in my eyes) not work, because $b=&array(0,1,2,3,4,5,6) does not work too.