PHP函数找出传入函数的参数个数? [英] PHP function to find out the number of parameters passed into function?

查看:26
本文介绍了PHP函数找出传入函数的参数个数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有 PHP 函数可以查找要接收/传递给特定函数的参数数量?

Is there a PHP function to find the number of parameters to be received/passed to a particular function?

推荐答案

func_num_args

获取传递给函数的参数数量.

Gets the number of arguments passed to the function.

这是从上面的链接中获取的示例,

Here is an example taken right from the link above,

<?php
function foo()
{
    $numargs = func_num_args();
    echo "Number of arguments: $numargs\n";
}

foo(1, 2, 3);   
?>

哪些输出,

Number of arguments: 3

这篇关于PHP函数找出传入函数的参数个数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆