func_num_args
(PHP 4, PHP 5, PHP 7, PHP 8)
Returns the number of arguments passed to the function
Description
Gets the number of arguments passed to the function.
This function may be used in conjunction with func_get_arg() and func_get_args() to allow user-defined functions to accept variable-length argument lists.
Parameters Parameters
Return Values
Returns the number of arguments passed into the current user-defined function.
Errors/Exceptions
Generates a warning if called from outside of a user-defined function.
Examples
func_num_args() example
<?php
function foo()
{
echo "Number of arguments: ", func_num_args(), PHP_EOL;
}
foo(1, 2, 3);
?>The above example will output:
Number of arguments: 3Notes Func-named-params
See Also
...syntaxfunc_get_arg()func_get_args()ReflectionFunctionAbstract::getNumberOfParameters