是否可以计算 PHP 函数中缺少的参数?我想做这个:
// I have this
function foo($param1, $param2, $param3) {
// I need some sort of argument counter
}
foo("hello", "world");
当我使用上面的 foo 函数时,我想要一种方法来找出并非所有参数都被使用。
通过计算所有参数并与 get_defined_vars() 进行比较,或者使用一个函数来计算缺失参数的数量。
编辑:如果打开 error_reporting 时缺少某些参数,我需要停止运行的方法。
if(!foo($param)) { echo "Couldn't Foo!"; }