PHP 外部获取函数参数个数
function War($a,$b,$c)
{
$n = func_num_args();
echo $n;
}
War(1,2,3);
func_num_args()这个函数只能在函数里面获取参数个数而不能在函数外部获取,有什么方法能在外部获取函数参数的个数呢?
--------------------------------------------------------------------------------
func_num_args()得到的是传递给宿主函数的参数个数
--------------------------------------------------------------------------------
func_num_args()得到的是实际传递的参数个数,而不是预定义个数,所以不应该有“外部获得”的说法
PHP code
function War()
{
$n = func_num_args();
echo $n;
}
War(1,2,3);
War(1,2,3,4);
War(1,2);
--------------------------------------------------------------------------------
实在要在“外部获取”倒是可以利用自定义函数的注释,用反射来获取
PHP code
/**
* 某自定义函数
*
* @param string $a
* @param string $b
* @param string $c
*/
function War($a,$b,$c){}
/**
* 某自定义函数2
*
* @param s……

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 Linux new version
SublimeText3 Linux latest version

Dreamweaver CS6
Visual web development tools

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool
