function test(){
  $args = func_get_args();
  echo array_sum($args);
}test(1,2,3,4);
希望对你有所帮助。

解决方案 »

  1.   

    楼上的误解了,我是想通过test来调用不同的函数,而test用一个参数就可以,但不同函数的参数是不固定的
      

  2.   

    可以直接将参数用数组传过去。就是$b。demo只设两个参数就行了。你最好写段完整程序。
    你这种说法绕来绕去的,我看着很别扭
      

  3.   


    <?php
    function takes_array($input)
    {
        echo "$input[0] + $input[1] = ", $input[0]+$input[1];
    }
    ?> 
    看这个对你有帮助没?
      

  4.   

    回4楼的function A($a="b",$b="b"){
        echo $a." and ".$b;
    }
    function B($b="b"){
        echo $b;
    }$exname = "B";
    $expar = "aa,bb";第一次
    $$exname($expar);
    输出结果为
    "aa,bb"
    第二次
    $exname = "A";
    $$exname($expar);
    输出结果为
    "aa,bb and "//当调用A函数时$expar只能当作参数$a传给函数A,但是我想实现效果为
    $$exname($expar);
    输出结果为
    "aa and bb"
    也就是说把expar的","两边分别传给函数A中的$a 和$b
      

  5.   

    那用下面的这个肯定能解决的了啊,一个数组参数,判断其长度就行了
    <?php
    function takes_array($input)
    {
        echo "$input[0] + $input[1] = ", $input[0]+$input[1];
    }
    ?>