Hi,
I'm trying to make some universal PHP library, which will be object based (I was inspired by PML)
But I have problem with class serialization in session...
try this code (two-way list):
<?
class test {
var $child, $parent, $name;
function test($nm) {
$this->name = $nm;
}
function registerchild($name) {
$this->child = new test($name);
$this->child->parent = & $this;
}
}
session_start();
if (!session_is_registered("main")) {
$main = new test("main");
$main->registerchild("childone");
$main->child->registerchild("childtwo");
$main->child->child->registerchild("childthree");
echo "first run"."<BR>";
}
$obj = & $main;
while (is_object($obj)) {
echo $obj->name."<BR>";
$obj = & $obj->child;
}
if (is_object($main)) {
echo "Main is object!<BR>";
}
$obj = & $main->child->child->child;
while (is_object($obj)) {
echo $obj->name."<BR>";
$obj = & $obj->parent;
}
session_register("main");
?>
The first run is OK, but the others are bad. Why??? Is it a bug or a feature (recursive classes forbidden)????
If you tell me, that I shouldn't pass whole class to session, it won't help me 🙂) But it seems that I should do it another way... (if nobody solves it)
Thanks
PeS