(PHP 4, PHP 5, PHP 7, PHP 8)
func_num_args — Returns the number of arguments passed to the function
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.
Esta função não possui parâmetros.
Returns the number of arguments passed into the current user-defined function.
Generates a warning if called from outside of a user-defined function.
Exemplo #1 func_num_args() example
<?php
function foo()
{
echo "Number of arguments: ", func_num_args(), PHP_EOL;
}
foo(1, 2, 3);
?>
O exemplo acima produzirá:
Number of arguments: 3
Nota:
A partir do PHP 8.0.0, a família de funções func_*() deve ser mais transparente em relação aos argumentos nomeados, tratando os argumentos como se fossem todos passados posicionalmente, e os argumentos ausentes são substituídos por seus valores padrão. Esta função ignora a coleção de argumentos variádicos nomeados desconhecidos. Argumentos nomeados desconhecidos que são coletados só podem ser acessados por meio do parâmetro variádico.
...
syntax