array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'uk', ), 'this' => array ( 0 => 'function.func-num-args.php', 1 => 'func_num_args', 2 => 'Returns the number of arguments passed to the function', ), 'up' => array ( 0 => 'ref.funchand.php', 1 => 'Function handling Функції', ), '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', ), 'history' => array ( ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); contributors($setup); ?>

func_num_args

(PHP 4, PHP 5, PHP 7, PHP 8)

func_num_argsReturns the number of arguments passed to the function

Опис

func_num_args(): int

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.

Параметри

У цієї функції немає параметрів.

Значення, що повертаються

Returns the number of arguments passed into the current user-defined function.

Помилки/виключення

Generates a warning if called from outside of a user-defined function.

Приклади

Приклад #1 func_num_args() example

<?php
function foo()
{
echo
"Number of arguments: ", func_num_args(), PHP_EOL;
}

foo(1, 2, 3);
?>

Поданий вище приклад виведе:

Number of arguments: 3

Примітки

Зауваження:

Починаючи з PHP 8.0.0, сімейство функцій func_*() стало більш прозорим щодо названих параметрів, обробляючи їх так, ніби всі передані позиційно, а пропущеним аргументам призначаються стандартні значення. Ця функція ігнорує набір невідомих названих варіативних параметрів. Набір невідомих названих параметрів доступний через варіативний параметр.

Прогляньте також