In PHP 3, it appears that when I construct an object and pass it into a method, it gets copied and the method operates on the copy. This poses a problem where I wasnt to have a tree structure of nodes -
<?
class Node
{
var $kids;
function Node()
{
$this->kids = array();
}
function add_child($node)
{
// This adds a COPY of node and not
// the actual node to the kids list
$this->kids[] = $node;
}
}
$root = new Node();
$child = new Node();
// I want to add child to the root node
$root->add_child($child);
?>
Is there any way to convince PHP3 to pass the object by reference and avoid the copy being worked on or is this a reason to move to PHP4?
Thanks!