Is there a way to call Static Classes / Methods by name?
Example:
$name = 'StaticClass';
($name)::foo();
I have classes which I keep all static methods in and I'd like to call them this way.
Is there a way to call Static Classes / Methods by name?
Example:
$name = 'StaticClass';
($name)::foo();
I have classes which I keep all static methods in and I'd like to call them this way.
Hi,
You can do something like this using the call_user_func function
it would look something like the following
$name = 'staticClass';
user_call_func(array($name, 'foo'));
Hope this helps
$name::foo()
is possible since PHP5.3. In earlier versions you have to use
call_user_func(array($classname,$methodname))