Object reference into variable?

From: Date: Tue, 07 Aug 2007 08:32:47 +0000
Subject: Object reference into variable?
Groups: php.general 
Request: Send a blank email to php-general+get-260266@lists.php.net to get a copy of this message
Hello, I have a question (what a surprise :-) ) I browsed the archives, but didn't find what I'm looking for. I have an object instance stored in some variable (like $myobject). I want to save this instance into another variable (like $tempobject). I thought, this will be the way: $myobject = new MyObject(); $tempobject = $myobject; (or I tried this too: $tempobject = &$myobject) None of them worked, like I cannot access methods in the object: $tempobject->Foo() gives me an error: calling to method on a non-object variable. How can I tell PHP that $tempobject is a class instance of MyObject, and that I can use it's methods? Thanks, SanTa

« previous php.general (#260266) next »