更新时间:2023-11-15 14:03:16
callback
语法在PHP中有点奇怪.您需要做的是创建一个数组.第一个元素是对象,第二个元素是方法.
The callback
syntax is a little odd in PHP. What you need to do is make an array. The 1st element is the object, and the 2nd is the method.
call_user_func(array($player, 'SayHi'));
您也可以在没有call_user_func
的情况下这样做:
You can also do it without call_user_func
:
$player->{'SayHi'}();
或者:
$method = 'SayHi';
$player->$method();