PHP 4.0 Bug #7511: References are not properly reassigned with classes

From: Date: Sat, 28 Oct 2000 12:13:21 +0000
Subject: PHP 4.0 Bug #7511: References are not properly reassigned with classes
Groups: php.dev 
Request: Send a blank email to php-dev+get-36229@lists.php.net to get a copy of this message
From: heathm@effinitylabs.com Operating system: RedHat Linux 7.0/6.2 PHP version: 4.0.3 PHP Bug Type: Class/Object related Bug description: References are not properly reassigned with classes I found a rather strange problem with reference to objects. Take the following: <?php class foo { var $Name; function foo($name) { $this->Name = $name; } } $bar = new foo('Mike'); $list[] =& $bar; //unset($bar); $bar = new foo('Jeremy'); $list[] =& $bar; while(list($key, $val) = each($list)) echo "<br>$key = $val->Name"; ?> When going through the loop and echoing the Name parameter the both return Jeremy. If I unset $bar first (by uncommenting it) it works fine. I'm not exactly sure what's going on but it is rather strange. Mike -- Edit Bug report at: http://bugs.php.net/?id=7511&edit=1

« previous php.dev (#36229) next »