PHP函数func_num_args用法实例分析_PHP

WBOY
Release: 2016-05-28 13:12:58
Original
933 people have browsed it

本文实例讲述了PHP函数func_num_args用法。分享给大家供大家参考,具体如下:

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);

Copy after login

运行结果如下:

Num fo argumets : 5 
Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 45 [4] => 6 ) 
--------------------------------------------------------------------------------
1
2
3
45
6

Copy after login

希望本文所述对大家php程序设计有所帮助。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template