<?php
function demo($num1,$num2,$num3,$num4,$num5=''){
// 只是调用的个数,实参
echo "the all parameter 's sum is ".$numargs=func_num_args()."<br>" ;
//返回指定位置参数值 ,超出会报错 func_get_arg(): Argument 31 not passed to function in 。。。
echo func_get_arg(3)."<br>";
// 得到实参数组
$arg_list = func_get_args();
for ($i = 0; $i < $numargs; $i++) {
echo "the parameter {$i} 's value is " .$arg_list[$i]."<br />\n";
}
return ($num1+$num2)-$num3*$num4;
}
echo demo(1,2,2,4);
output:
the all parameter 's sum is 4
4
the parameter 0 's value is 1
the parameter 1 's value is 2
the parameter 2 's value is 2
the parameter 3 's value is 4
-5