Re: calling static methods of variable class names
| From: | Oliver Grätz | Date: | Tue, 22 Nov 2005 13:48:53 +0000 |
| Subject: | Re: calling static methods of variable class names | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-226264@lists.php.net to get a copy of this message | ||
Ahmed Saad schrieb:
> hi all,
>
> how can i call static methods of a class whose name is variable.. something like
> <? $className::doSomething(); // throws a parser error ?>
> I can do this with reflection by creating a ReflectionMethod object
> then invoke()ing it, but is there a better way?
> Thanks
>
> -ahmed
For
$args=array('para1','para2');
use
call_user_func(array($className,'doSomething'),$args[0],$args[1]);
or
call_user_func_array(array($className,'doSomething'),$args);
Have Fun!
OLLi