#19738 [Opn->Ver]: Getting reference instead of copy of object

From: Date: Fri, 04 Oct 2002 03:09:50 +0000
Subject: #19738 [Opn->Ver]: Getting reference instead of copy of object
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-21443@lists.php.net to get a copy of this message
ID: 19738 Updated by: iliaa@php.net Reported By: team@anahoret.com -Status: Open +Status: Verified Bug Type: Scripting Engine problem Operating System: Linux, Windows PHP Version: 4.2.3 Previous Comments: ------------------------------------------------------------------------ [2002-10-03 10:15:34] team@anahoret.com Normally this code should print "0", however, when uncommenting a single empty method call, it outputs "1". It seems like a copy suddenly becomes a reference. <?php $a1 = new A(); //$a1->c->f(); // uncomment this to expose error. $a2 = $a1; $a2->c->x = 1; echo $a1->c->x; class C { var $x = 0; function f() {} } class A { var $c; function A() { $this->c = new C(); } } ?> Thanks. Anahoret Team. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=19738&edit=1

« previous php.bugs (#21443) next »