is possible get reference to static function and run? like this:
namespace vendor\foo;
class Bar
{
public static function f1()
{
echo 'f1';
}
public static function f2($id)
{
echo 'f2: '.$id;
}
}
and
$fs = array(
'f1'=>\vendor\foo\Bar::f1,
'f2'=>\vendor\foo\Bar::f2
);
$fs['f1']();
$fs['f2']('some id');
or the only way is call_user_func ?
note: php 5.3
You have multiple options to do this
The following examples shall demonstrate these options:
Option 1 : Using a string variable for the classname and the method name:
Option 2 : Perpare a callback variable and pass it to
call_user_func():Option 3 : Use ReflectionMethod::invoke() :