PHP中call_user_func_array回調(diào)函數(shù)的用法示例
call_user_func_array
call_user_func_array
— 調(diào)用回調(diào)函數(shù),并把一個數(shù)組參數(shù)作為回調(diào)函數(shù)的參數(shù)
mixed call_user_func_array ( callable $callback , array $param_arr )
把第一個參數(shù)作為回調(diào)函數(shù)(callback)調(diào)用,把參數(shù)數(shù)組作(param_arr)為回調(diào)函數(shù)的的參數(shù)傳入。
例子:
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 arguments call_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"));
輸出結(jié)果:
foobar got one and two foo::bar got three and four
總結(jié)
以上就是這篇文章的全部內(nèi)容了,希望本文的內(nèi)容對大家學(xué)習(xí)或者使用PHP能有所幫助,如果有疑問大家可以留言交流。
- PHP將回調(diào)函數(shù)作用到給定數(shù)組單元的方法
- JS回調(diào)函數(shù)原理與用法詳解【附PHP回調(diào)函數(shù)】
- PHP回調(diào)函數(shù)簡單用法示例
- PHP回調(diào)函數(shù)及匿名函數(shù)概念與用法詳解
- PHP回調(diào)函數(shù)概念與用法實例分析
- PHP回調(diào)函數(shù)與匿名函數(shù)實例詳解
- PHP 使用MySQL管理Session的回調(diào)函數(shù)詳解
- PHP 的異常處理、錯誤的拋出及回調(diào)函數(shù)等面向?qū)ο蟮腻e誤處理方法
- php回調(diào)函數(shù)處理數(shù)組操作示例
相關(guān)文章
探討多鍵值cookie(php中cookie存取數(shù)組)的詳解
本篇文章是對多鍵值cookie(php中cookie存取數(shù)組)進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下2013-06-06php字符比較函數(shù)similar_text、strnatcmp與strcasecmp用法分析
這篇文章主要介紹了php字符比較函數(shù)similar_text、strnatcmp與strcasecmp用法,以實例形式詳細(xì)分析了這三個字符串比較函數(shù)的具體用法,非常具有實用價值,需要的朋友可以參考下2014-11-11