func_num_args()

func_num_args() — Returns the number of arguments passed to the function.

Built-in function of PHP 8.5. The manual lists it as available in PHP 4, PHP 5, PHP 7, PHP 8. This page is the reference card: signature, parameters and return value, plus the changelog and the example the manual provides.

Signature

func_num_args(): int

Parameters

This function takes no parameters.

Return value

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

Example

A runnable snippet:

function foo() { echo "Number of arguments: ", func_num_args(), PHP_EOL; } foo(1, 2, 3);

Output:

Number of arguments: 3

See also

func_get_arg(), func_get_args()

All PHP 8.5 built-in functions

Reference card built from the PHP manual page func_num_args() (PHP documentation, CC BY 3.0). The page is generated from the manual, so the wording of the parameter and return value text follows php.net.