call_user_func_array
call_user_func_array — 調用回調函數,并把一個數組參數作為回調函數的參數
mixed call_user_func_array ( callable $callback , array $param_arr )
把第一個參數作為回調函數(callback)調用,把參數數組作(param_arr)為回調函數的的參數傳入。
例子:
function foobar($arg, $arg2) { echo __FUNCTION__, " got $arg and $arg2/n";}class foo { function bar($arg, $arg2) { echo __METHOD__, " got $arg and $arg2/n"; }}// Call the foobar() function with 2 argumentscall_user_func_array("foobar", array("one", "two"));dump("<br/>");// Call the $foo->bar() method with 2 arguments$foo = new foo;call_user_func_array(array($foo, "bar"), array("three", "four"));輸出結果:
foobar got one and twofoo::bar got three and four
總結
以上就是這篇文章的全部內容了,希望本文的內容對大家學習或者使用PHP能有所幫助,如果有疑問大家可以留言交流。
新聞熱點
疑難解答
圖片精選