Hello,
is it possible in php to correctly serialize objects wich contain other object references?
let's say we have a class like the following:
class MyClass {
var $members;
var $parent;
function setParent(&$parent) {
$this->_parent = $parent;
}
function getRoot() {
if ($this->isRoot()) return $this;
else return $this->_parent->getRoot();
}
...
}
there is one root class which holds several classes of same type, and these classes again recursively hold classes and so on.
when i serialize this class the references seem to get turned into values. so when i change the root class and call getRoot() in a subclass the old root is returned.
Seems to me like php always serializes member variables to values?
Can anyone tell me what i am doing wrong?
thanks,
tom