From: [EMAIL PROTECTED] Operating system: Windows XP SP1 PHP version: 4.3.0 PHP Bug Type: Arrays related Bug description: PHP does referencing when i want to create a *copy* of an array of objects
Hello, i have some problems with understanding the following: class Test { var $a; function Test() { $this->a = 0; } function test2() { } } $a[0] = new Test; $b = $a; $a[0]->a = 1; echo($b[0]->a); This outputs 0 as i would expect..but: $a[0] = new Test; $a[0]->test2(); $b = $a; $a[0]->a = 1; echo($b[0]->a); This outputs 1, and i dont understand this, PHP seems to do some sort of referencing here, though i dont want any.. $b[0] = $a[0]; works and creates a real copy, but i was still wondering if $b = $a shouldnt create a copy aswell instead of this referencing stuff... -- Edit bug report at http://bugs.php.net/?id=21288&edit=1 -- Try a CVS snapshot: http://bugs.php.net/fix.php?id=21288&r=trysnapshot Fixed in CVS: http://bugs.php.net/fix.php?id=21288&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=21288&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=21288&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=21288&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=21288&r=support Expected behavior: http://bugs.php.net/fix.php?id=21288&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=21288&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=21288&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=21288&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=21288&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=21288&r=dst IIS Stability: http://bugs.php.net/fix.php?id=21288&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=21288&r=gnused