note 101937 deleted from keyword.extends by danbrown

From: Date: Wed, 19 Jan 2011 15:27:34 +0000
Subject: note 101937 deleted from keyword.extends by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-175893@lists.php.net to get a copy of this message
Note Submitter: JamesM ---- I have improved (f4bi0_ at hotmail dot com)'s answer to many extends. :) <?php class test { private $_MODS; public function __construct ( $mods ) { $mods ? $this->_MODS = $mods : void; } public function __get( $var ) { foreach ( $this->_MODS as $mod ) if ( property_exists( $mod, $var ) ) return $mod -> $var; } public function __call( $method, $args ) { foreach ( $this->_MODS as $mod ) if ( method_exists( $mod, $method ) ) return call_user_method_array( $method, $mod, $args ); } } $mods = array(); class mod_test { public function echoText ($text){ echo $text; return true; } } $mods[] = new mod_test(); $test = new test($mods); var_dump($test); echo $test -> getText(); ?> It works great, feel free to notify me with an even better way to do this (jamesm.sitegen/gmail

« previous php.notes (#175893) next »