array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'pt_BR', ), 'this' => array ( 0 => 'function.func-num-args.php', 1 => 'func_num_args', ), 'up' => array ( 0 => 'ref.funchand.php', 1 => 'Funções para Manuseamento de Funções', ), 'prev' => array ( 0 => 'function.func-get-args.php', 1 => 'func_get_args', ), 'next' => array ( 0 => 'function.function-exists.php', 1 => 'function_exists', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'reference/funchand/functions/func-num-args.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(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