Bug #12365 Updated: Problems with classes and links to objects
| From: | mfischer@php.net | Date: | Sat, 17 Nov 2001 18:47:17 +0000 |
| Subject: | Bug #12365 Updated: Problems with classes and links to objects | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-70749@lists.php.net to get a copy of this message | ||
ID: 12365
Updated by: mfischer
Reported By: vbv@arte.ru
Old Status: Open
Status: Closed
Bug Type: Class/Object related
Operating System: Linux
PHP Version: 4.0.6
New Comment:
I said closed :-)
Previous Comments:
------------------------------------------------------------------------
[2001-11-17 13:47:03] mfischer@php.net
The object $this used in the constructor is not the same as the one returned to $b because it got
copied. Assign the new object by reference to $b:
$b = &new b();
Closed.
------------------------------------------------------------------------
[2001-07-25 10:11:26] vbv@arte.ru
<?
phpinfo();
class a {
function a ($obj) {
$this->h = &$obj;
return true;
}
}
class b {
var $d=1;
var $item;
function b () {
$this->item = new a (&$this);
$this->d++;
echo $this->d.'//'.$this->item->h->d.'<br>'; }
function c () {
$this->item = new a (&$this);
}
}
$b = new b ();
//$b->c (); //****
$b->d++;
echo $b->d.'--'.$b->item->h->d;
/*
Try to comment and recomment line ****
I see there is a bug with that sitution:
after finishing of object "b" constructor, link $a->h not linked to "b"
object and $a->h is a copy of object "b".
I think, this is not right. In constructor $a->h is still link to "b", but after
finishing the $a->h is a copy of "b".
*/
------------------------------------------------------------------------
Edit this bug report at http://bugs.php.net/?id=12365&edit=1