PHP函数的重载函数call_user_func_array 简单

[php]
<?php
// @copyright Copyright (c) 2009 侯惠阳 (www.163y.cn)
// @author phper.yang@gmail.com
// @version 1.0

function otest1 ($a)
{
echo( '一个参数' );
echo $a;
}

function otest2 ($a, $b)
{
echo( '二个参数' );
echo $a.$b;
}
function otest3 ( $a ,$b,$c)
{
echo( '三个啦' );
echo $a.$b.$c;
}
function otest ()
{
        $args = func_get_args();//函数传回一数组,数组的各个元素相当于是目前使用者定义函式的参数列的数目。
  print_r($args);
       echo $num = func_num_args();//返回传递到函数的参数数目
        call_user_func_array('otest'.$num, $args);   
}
//otest(1);
//otest(1,2);
otest(1,2,3);
[/php]
原文地址:https://www.cnblogs.com/xiangxiaodong/p/1959578.html