PHP 4.0 Bug #7511 Updated: References are not properly reassigned with classes
| From: | waldschrott@php.net | Date: | Sat, 28 Oct 2000 13:16:40 +0000 |
| Subject: | PHP 4.0 Bug #7511 Updated: References are not properly reassigned with classes | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-36257@lists.php.net to get a copy of this message | ||
ID: 7511
Updated by: waldschrott
Reported By: heathm@effinitylabs.com
Status: Closed
Bug Type: Class/Object related
Assigned To:
Comments:
no bug here, here´s what you did...
1) created instance of foo on uninitialized $bar
2) created a reference in array $list to $bar
(read the chapter "references explained in the manual" if
you don´t understand the following)
3) created instance of foo on $bar and it´s referenced array
element
4) created another reference in array $list to $bar
finally there are 3 structures beeing the same, $bar, array
element 1, array element 2
Previous Comments:
---------------------------------------------------------------------------
[2000-10-28 08:13:21] heathm@effinitylabs.com
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
---------------------------------------------------------------------------
Full Bug description available at: http://bugs.php.net/?id=7511