Object Copying
| From: | Ken Kinder | Date: | Thu, 10 Jan 2002 23:40:17 +0000 |
| Subject: | Object Copying | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-80113@lists.php.net to get a copy of this message | ||
As we all know, this copies an object in PHP:
$obj2 = $obj1
Assuming $obj1 is an object (of a class).
I want this never, ever to happen unless I want it to. All the time, I run
into something where PHP made a copy of my object for X odd reason -- I pass
an object to a function, I put it in an array, etc etc etc. Is there a way I
can have PHP warn me if an object is copied, or put that in the class code
somehow?
Preferable a way to fix PHP not to copy the object, but the reference. I'd
settle for a warning system though.