#29441 [Opn->Bgs]: After copying a class, changes to new class affect old class.

From: Date: Mon, 02 Aug 2004 10:56:03 +0000
Subject: #29441 [Opn->Bgs]: After copying a class, changes to new class affect old class.
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-63917@lists.php.net to get a copy of this message
ID: 29441 Updated by: derick@php.net Reported By: php at cyruslesser dot com -Status: Open +Status: Bogus Bug Type: Class/Object related Operating System: Linux Debian PHP Version: 5.0.0 New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php . Previous Comments: ------------------------------------------------------------------------ [2004-07-29 08:44:27] php at cyruslesser dot com Description: ------------ This may just be my mis-understanding of how the language should work, but surely when you copy an object (class) and make changes to it, those changes shouldn't affect the original object? I don't really see the point in making a copy of an object, if the changes you make to the new copy affect the old copy. If I'm just dumb, then I apologise. Reproduce code: --------------- <? class c { var $i = 0; }; $a = new c; $a->i = 1; $b = $a; $b->i = 2; echo "a: $a->i"; echo "b: $b->i"; ?> Expected result: ---------------- a: 1 b: 2 Actual result: -------------- a: 2 b: 2 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=29441&edit=1

« previous php.bugs (#63917) next »