mixed func_get_arg ( int $arg_num )
该函数用于返回所在函数中指定索引的参数,索引从0开始
1 <?php 2 function foo() 3 { 4 $numargs = func_num_args(); 5 echo "Number of arguments: $numargs<br />\n"; 6 if ($numargs >= 2) { 7 echo "Second argument is: " . func_get_arg(1) . "<br />\n"; 8 } 9 } 10 11 foo (1, 2, 3); 12 ?>
array func_get_args ( void )
则将所有参数以数组形式返回
1 <?php 2 function foo() { 3 include './fga.inc'; 4 } 5 6 foo('First arg', 'Second arg'); 7 ?> 8 9 fga.inc 10 <?php 11 12 $args = func_get_args(); 13 var_export($args); 14 15 16 //print : array ( 17 // 0 => 'First arg', 18 // 1 => 'Second arg', 19 // ) 20 21 ?>
int func_num_args ( void )
返回函数参数的总数
1 <?php 2 function foo() 3 { 4 $numargs = func_num_args(); 5 echo "Number of arguments: $numargs\n"; 6 } 7 8 foo(1, 2, 3); 9 10 //print : Number of arguments: 3 11 ?>