Calling a static method with call_user_method?
| From: | Arjen Brouwer | Date: | Sun, 18 May 2003 13:08:36 +0000 |
| Subject: | Calling a static method with call_user_method? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-148077@lists.php.net to get a copy of this message | ||
Hi!
Is it possible to call a static method from a object with call_user_func? Cause call_user_method
needs an instance of an object as parameter, you can't pass a name of a class in a string.
Instead of this:
<?
car::paint("Black");
?>
I would like to do:
<?
$class = "car";
$method = "paint";
$parameters = "Black";
call_user_func_array($class, $method, $parameters);
?>
But it won't work.
The same for:
<?
$class = "car";
$method = "paint";
$parameters = "Black";
$$class::$method($parameters);
--OR--
$class::$method($parameters);
?>
Cheers,
Arjen