note 16421 added to language.oop
| From: | dougqh at hotmail dot com | Date: | Mon, 29 Oct 2001 19:29:59 +0000 |
| Subject: | note 16421 added to language.oop | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-19575@lists.php.net to get a copy of this message | ||
If you want to call a method of class and you do not have an instance of the class and you have the
class, method name, or both stored in a variable(s) you can use the following ...
call_user_func( array( $className, $functionName ), [ $param0 [, $param1 [, ... ] ] ] )
For example
$class = "MyClass";
$method = "myMethod";
call_user_func( array( $class, $method ), 0, 1 );
is equivalent to
MyClass::myMethod( 0, 1 );
--
http://www.php.net/manual/en/language.oop.php
http://master.php.net/manage/user-notes.php?action=edit+16421
http://master.php.net/manage/user-notes.php?action=delete+16421
http://master.php.net/manage/user-notes.php?action=reject+16421