_vars = array(); $this->_next = null; } private function __get($name) { if($name == "_last"){ $last =& $this; while($last->_next != null) $last =& $last->_next; return $last; } if(isset($this->_vars[$name])) return $this->_vars[$name]; else throw new Exception("'$name' not found."); } private function __set($name, $val) { $this->_vars[$name] = $val; } } /* Usage */ for($i = 0; $i < 10; $i++){ if(!isset($sll)){ $sll = new sllist(); $sll->name = "child{$i}"; }else{ $sll->_last->_next = new sllist($sll); $sll->_last->name = "child{$i}"; } } var_dump($sll); ?>