Blogger Information
Blog 263
fans 3
comment 2
visits 113343
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
获取函数参数和参数的运用
福哥的博客
Original
1012 people have browsed it
<?php
function foo()
{
    $numargs = func_num_args();//返回给函数传递的参数个数
    echo "Number of arguments: $numargs ";
}

foo(1, 2, 3);   

//以上例程会输出:

 //Number of arguments: 3
?>
<?php
function foo()
{
    $numargs = func_get_args();//返回给函数传递的参数
    print_r($numargs);
   
}

foo('a', 'b', 'c');   

//以上例程会输出:

 //Array ( [0] => a [1] => b [2] => c ) 
?>
<?php
function foo()
{
    $numargs = func_get_arg(0);//返回给函数传递的参数个数
    echo "Number of arguments: $numargs ";
}

foo('a', 'b', 'c');  

//以上例程会输出:

 //The argument is: a
?>
<?php
function foo() {
    include './fna.php';
}

foo('First arg', 'Second arg');
?>

fna.php
<?php

$num_args = func_num_args();
var_export($num_args);

?>


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