note 35258 added to language.types.object

From: Date: Mon, 25 Aug 2003 19:26:40 +0000
Subject: note 35258 added to language.types.object
Groups: php.notes 
Request: Send a blank email to php-notes+get-55059@lists.php.net to get a copy of this message
PHP supports recursive type definitions as far as I've tried. The class below (a _very_ simple tree) is an example: class Tree { var $_value = null; var $_children = array(); function Tree ($value) { $this->_value = $value; } function addChild ($value) { $aux_node = new Tree ($value); $this->_children [] = $aux_node; return $aux_node; } } As you can see, in addChild we reference Tree again... However, you must be careful about references. See the chapter "References explained" for more details. Hope this helps. ---- Manual Page -- http://www.php.net/manual/en/language.types.object.php Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+35258 Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+35258&report=yes Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+35258&report=yes

« previous php.notes (#55059) next »