The example in this article describes the usage of PHP function func_num_args. Share it with everyone for your reference, the details are as follows:
function foo() { $numargs = func_num_args();//返回这个函数所含的参数 echo "Num fo argumets : $numargs <br>\n"; $arr=func_get_args();//返回一个数组给$arr print_r($arr);//输出这个数组所有的参数 echo "<hr>"; for($i=0;$i<=$numargs;$i++) { echo $arr[$i]."<br>"; } } foo(1,2,3,45,6);
The running results are as follows:
Num fo argumets : 5 Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 45 [4] => 6 ) -------------------------------------------------------------------------------- 1 2 3 45 6
I hope this article will be helpful to everyone in php programming.