Blogger Information
Blog 3
fans 0
comment 0
visits 2367
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
func_num_args() 和 func_get_args()
白天的博客
Original
745 people have browsed it

func_num_args()  传递给函数的参数个数

func_get_args()    传递给函数的参数数组

例子:

<?php  

function foo()  

{  

    $numargs = func_num_args();  

    echo "Number of arguments: $numargs<br />\n";  

    if ($numargs >= 2) {  

        echo "Second argument is: " . func_get_arg(1) . "<br />\n";  

    }  

    $arg_list = func_get_args();  

    for ($i = 0; $i < $numargs; $i++) {  

        echo "Argument $i is: " . $arg_list[$i] . "<br />\n";  

    }  

}  

  

foo(1, 2, 3); 

输出:

Number of arguments: 3
Second argument is: 2
Argument 0 is: 1
Argument 1 is: 2
Argument 2 is: 3


Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post