如何通过名称调用普通(非静态)类函数? p>
下面给出了一个错误,说param 1需要是一个有效的回调。 我不希望函数是静态的,我希望它是一个普通的函数,到目前为止我见过的所有例子都是静态的。 p>
class Player
{
公共函数SayHi(){print(“Hi”); }
}
$ player = new Player();
call_user_func($ Player,'SayHi');
code> pre>
div>
How can I call a normal (not static) class function by its name?
The below gives an error saying param 1 needs to be a valid callback. I don't want the function to be static, I want it to be a normal function, and all the examples I've seen so far had them static.
class Player
{
public function SayHi() { print("Hi"); }
}
$player = new Player();
call_user_func($Player, 'SayHi');
如何通过名称调用普通(非静态)类函数? p>
下面给出了一个错误,说param 1需要是一个有效的回调。 我不希望函数是静态的,我希望它是一个普通的函数,到目前为止我见过的所有例子都是静态的。 p>
class Player
{
公共函数SayHi(){print(“Hi”); }
}
$ player = new Player();
call_user_func($ Player,'SayHi');
code> pre>
div>