《PHP实例:PHP中call_user_func_array回调函数的用法示例》要点:
本文介绍了PHP实例:PHP中call_user_func_array回调函数的用法示例,希望对您有用。如果有疑问,可以联系我们。
call_user_func_arrayPHP学习
call_user_func_array
― 调用回调函数,并把一个数组参数作为回调函数的参数PHP学习
mixed call_user_func_array ( callable $callback , array $param_arr )
把第一个参数作为回调函数(callback)调用,把参数数组作(param_arr)为回调函数的的参数传入.PHP学习
例子:PHP学习
function foobar($arg, $arg2) { echo __FUNCTION__, " got $arg and $arg2n";}class foo { function bar($arg, $arg2) { echo __METHOD__, " got $arg and $arg2n"; }}// 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"));
输出结果:PHP学习
foobar got one and twofoo::bar got three and four
总结PHP学习
以上就是这篇文章的全部内容了,希望本文的内容对大家学习或者使用PHP能有所帮助,如果有疑问大家可以留言交流.
PHP学习
希望以上内容对你有所帮助!如果还有其他问题,请随时提问。 各类知识收集 拥有多年CMS企业建站经验,对 iCMS, LeCMS, ClassCMS, Fastadmin, PbootCMS, PHPCMS, 易优CMS, YzmCMS, 讯睿CMS, 极致CMS, Wordpress, HkCMS, YznCMS, WellCMS, ThinkCMF, 等各类cms的相互转化,程序开发,网站制作,bug修复,程序杀毒,插件定制都可以提供最佳解决方案。