Dynamically Adding methods to an object

From: Date: Sun, 01 Dec 2002 08:04:50 +0000
Subject: Dynamically Adding methods to an object
Groups: php.general 
Request: Send a blank email to php-general+get-126680@lists.php.net to get a copy of this message
Hello, I want to add a method to an existing object. Any ideas how to? I tried using foreach($this->modules->$module_name->methods as $mod_method => $method_name) { $function = '$args = implode(",", func_get_args());'; $function .= 'return mod_'.$module_name.'::'.$mod_method.'($args);'; $lambda = create_function('', $function); $lambda(1); $this->$method_name = $lambda; } The error I got was "Fatal error: func_get_args(): Can't be used as a function parameter in ...: runtime-created function on line 1" when I called $lambda() Is there a way I can know the arguments of a defined method without calling the method? Thank you, Brian Takita

« previous php.general (#126680) next »