首页 > 编程语言 > 详细

call_user_func_array — 调用回调函数,并把一个数组参数作为回调函数的参数

时间:2019-12-24 16:28:54      阅读:196      评论:0      收藏:0      [点我收藏+]

技术分享图片

<?php
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"));

// 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 two
foo::bar got three and four

call_user_func_array — 调用回调函数,并把一个数组参数作为回调函数的参数

原文:https://www.cnblogs.com/clubs/p/12091775.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!