Hi everybody,

I want to wrote a function that receives another function as parameter that will be used as a Callback. Well, better a bit of code than thousand words:

class TreeNode {
...
   function Traverse ( CallBack ) {
       $rtn = CallBack ($this);
       foreach ($this->Sons as $Son) {
           $Son->Traverse ( CallBack );
       }
       return $rtn;
   }
...
}

And later I'll do something as:

function CallBack ( $Node ) {
   echo $Node->Name;
}

$MyTreeNode->Traverse ( CallBack );

...

Hope you understand what I'm trying to do. Can it be done as is or am I on the wrong way?

Thx. a million in advance,

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to