copy() method on objects

From: Date: Mon, 26 Apr 2010 04:24:55 +0000
Subject: copy() method on objects
Groups: php.general 
Request: Send a blank email to php-general+get-304583@lists.php.net to get a copy of this message
Here is some code: $a = new my_object; $b = $a; My understanding of this operation under PHP 5+ is that $b will now be essentially a "reference" to $a, *not* a *copy* of the $a object. Is this correct? There are cases where I strictly want a *copy* of $a stored in $b. In cases like this, I supply $a's class with a copy() method, and call it like this: $b = $a->copy(); Is this reasonable, or do people have a better/more correct way to do this? Paul -- Paul M. Foster

« previous php.general (#304583) next »