sorry for the confusion (and terrible example!)
I actually am using both of those methods already.. I'll update the code example:
Code: Select all
$thing = new Thing; // I have a thing
$subThing = $thing->changeFocus();
$origThing = $thing->returnOuterThing();
class Thing{
var $var;
function returnOuterThing(){
//..... ???????
}
function changeFocus(){
$this->var = new Thing; // the thing contains a thing
return $this->var;
}
}
when I try setting a parent using:
Code: Select all
function changeFocus(){
$this->var = new Thing; // the thing contains a thing
$this->var->parent = $this;
return $this->var;
}
I get:
Object of class Thing could not be converted to string
and usnig a reference gives me:
Code: Select all
function changeFocus(){
$this->var = new Thing; // the thing contains a thing
$this->var->parent = &$this;
return $this->var;
}
I get:
Cannot assign by reference to overloaded object
EDIT: DOH! I can't mix overloading and assigning by reference. When I removed the overloading (__get and __set) it works. While I'm satisfied for now (since I don't yet require overloading) does anyone have a way around this?