|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[1999-04-20 15:42 UTC] andi
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 07 20:00:02 2026 UTC |
I have experienced "working on a copy"-problem with one object and two variables containing the object. Example: (Untested) <? class someobject { var $a=4; } $myobj = new someobject; $ref1 = $myobj; $ref2 = $myobj; $ref2->a = 5; ?> Now ref1 is a someobject where a=4 and ref2 is a someobject where a = 5. I would expect that ref1 and ref2 points to the same object and thus the assignment ref1->a=5 will cause the object referenced by ref1 and ref2 to be updated since it is the same object. <br><br> This is very annoying and the whole point of having objects and classes seems to disappear, except for their "functionality-wrapping" features.