Re: cloning $this php5

From: Date: Fri, 11 May 2007 20:05:55 +0000
Subject: Re: cloning $this php5
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-254818@lists.php.net to get a copy of this message
Actually, the error seems to be coming with inner objects call some of their methods. For example the object as a datamember that is a reference to another object. When I clone it, I can't seem to call methods on the data member object. Thanks! On 5/11/07, blackwater dev <blackwaterdev@gmail.com> wrote:
I have a method within an class that should make a copy of itself, do some stuff on the copy and return it. The object contains data members that are references to other objects. I basically want a brand new copy of the object. The problem is, certain methods I call on the object throw this error: Call to undefined method stdClass::methodname I've tried to copy it with just =, =& and clone but they all through errors. What am I doing wrong? Thanks! function morph(){ $cloned_ob= clone $this; $cloned_ob->run(); $cloned_ob->data_member="john"; return $cloned_ob; }


« previous php.general (#254818) next »