我确信对此有一个非常简单的解释.这有什么区别:
function barber($type){
echo "You wanted a $type haircut, no problem\n";
}
call_user_func('barber', "mushroom");
call_user_func('barber', "shave");
Run Code Online (Sandbox Code Playgroud)
......这个(有什么好处?):
function barber($type){
echo "You wanted a $type haircut, no problem\n";
}
barber('mushroom');
barber('shave');
Run Code Online (Sandbox Code Playgroud) function foobar($arg, $arg2) {
echo __FUNCTION__, " got $arg and $arg2\n";
}
foobar('one','two'); // OUTPUTS : foobar got one and two
call_user_func_array("foobar", array("one", "two")); // // OUTPUTS : foobar got one and two
Run Code Online (Sandbox Code Playgroud)
我可以看到常规call_user_func_array方法和 方法都输出相同,那么为什么要选择它呢?
在哪种情况下,常规调用方法会失败,但call_user_func_array不会?
我能得到这样的例子吗?
谢谢