Bug #17697 Updated: Object in object (object->reference object)

From: Date: Tue, 11 Jun 2002 13:25:15 +0000
Subject: Bug #17697 Updated: Object in object (object->reference object)
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-10105@lists.php.net to get a copy of this message
ID: 17697 Updated by: mfischer@php.net Reported By: netadmin@isp.pl -Status: Open +Status: Closed Bug Type: Class/Object related Operating System: Red Hat 7.1 PHP Version: 4.2.1 New Comment: This is fixed in the Zend Engine 2, see php.net for the preview announcement. Previous Comments: ------------------------------------------------------------------------ [2002-06-11 09:03:12] netadmin@isp.pl <? class A { var $var_a; function A() { $this->set_a("old"); } function set_a($a) { $this->var_a=$a; } } class B { var $obj_a; function B() { $this->obj_a=new A; } } $my=new B; var_dump($my); $my->obj_a->set_a("new"); var_dump($my); ?> I create new object from class B ($my) variable $obj_a in object $my IS OBJECT from class A. var_dump($my) return object(b)(1) { ["obj_a"]=> object(a)(1) { ["var_a"]=> string(3) "old" } } It's ok. After that I call a method from class A $my->obj_a->set_a("new"); This method change variable $var_a, but after that variable $obj_a IS REFERENCE to object A var_dump($my) return : object(b)(1) { ["obj_a"]=> &object(a)(1) { ["var_a"]=> string(3) "new" } } $obj_a was object, but now $obj_a is reference to object. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=17697&edit=1

« previous php.bugs (#10105) next »