Hello!
I made a class which should represent a tree-like structure (PHP 4.3.8). I made a root-nore and added 2 childs. The problem is that the childs are not added to the parent. Why?
Martin
class TreeItem
{ var $m_pParent;
var $m_sName;
var $m_arrChilds = array(); function TreeItem($pParent, $sName)
{ $this->m_pParent = $pParent;
$this->m_sName = $sName;
if ($pParent != NULL)
$pParent->AddChild($this);
}
function AddChild($pTreeItem)
{ array_push($this->m_arrChilds, $pTreeItem);
}
} $root = new TreeItem(NULL, "Root");
$child1 = new TreeItem($root, "Child 1");
$child2 = new TreeItem($root, "Child 2");
print Count($root->m_arrChilds); // Outputs 0. Why????-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

