时时商务社区

标题: 解析php中call_user_func_array的作用 [打印本页]

作者: 新格网络    时间: 2018-2-14 08:21

            一、直接调用方法
[U]复制代码[/U] 代码如下:
function test($a, $b)
{
echo '测试一:'.$a.$b;
}
//调用test方法,array("asp", 'php')对应相应的参数
call_user_func_array('test', array("asp", 'php'));
二、通过类调用类中的方法
[U]复制代码[/U] 代码如下:
class test2{
function phpSay($a, $b)
{
echo '测试二:'.$a.$b;
}
}
$o = new test2();
//相当于:$o->phpSay('php','你好');
call_user_func_array(array(&$o, 'phpSay'), array('php','你好'));
            
            
您可能感兴趣的文章:
  • php自定义函数call_user_func和call_user_func_array详解
  • PHP中call_user_func_array()函数的用法演示
  • PHP 的异常处理、错误的抛出及回调函数等面向对象的错误处理方法
  • PHP 使用MySQL管理Session的回调函数详解
  • PHP 函数call_user_func和call_user_func_array用法详解
  • PHP将回调函数作用到给定数组单元的方法
  • ThinkPHP自动完成中使用函数与回调方法实例
  • PHP实现通过正则表达式替换回调的内容标签
  • php微信浏览器分享设置以及回调详解
  • PHP中call_user_func_array回调函数的用法示例
            




    欢迎光临 时时商务社区 (http://bbs.4435.cn/) Powered by Discuz! X3.2