#19738 [NEW]: Getting reference instead of copy of object

From: Date: Thu, 03 Oct 2002 15:15:34 +0000
Subject: #19738 [NEW]: Getting reference instead of copy of object
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-21389@lists.php.net to get a copy of this message
From: team@anahoret.com Operating system: Linux, Windows PHP version: 4.2.3 PHP Bug Type: Scripting Engine problem Bug description: Getting reference instead of copy of object 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 bug report at http://bugs.php.net/?id=19738&edit=1 -- Try a CVS snapshot: http://bugs.php.net/fix.php?id=19738&r=trysnapshot Fixed in CVS: http://bugs.php.net/fix.php?id=19738&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=19738&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=19738&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=19738&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=19738&r=support Expected behavior: http://bugs.php.net/fix.php?id=19738&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=19738&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=19738&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=19738&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=19738&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=19738&r=dst

« previous php.bugs (#21389) next »