class cls
{
public function test()
{
echo 'test';
}
}
$className = 'cls';
$className = new $className.'()';
$fun = 'test()';
$className->$fun;
call_user_func(array($className, $fun));
都不行,请问我想通过变量来调用对应的类和方法,应该怎么操作呢?
class cls { public function test() { echo 'test'; }} $className = 'cls';$instance = new $className();$instance->test();$fun = 'test';$instance->$fun(); call_user_func(array($instance, $fun));