<?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!