func_get_args()

func_get_args() — Returns an array comprising a function's argument list.

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_get_args(): array

Parameters

This function takes no parameters.

Return value

Returns an array in which each element is a copy of the corresponding member of the current user-defined function's argument list.

Example

A runnable snippet:

function foo() { $numargs = func_num_args(); echo "Number of arguments: $numargs \n"; if ($numargs >= 2) { echo "Second argument is: " . func_get_arg(1) . "\n"; } $arg_list = func_get_args(); for ($i = 0; $i < $numargs; $i++) { echo "Argument $i is: " . $arg_list[$i] . "\n"; } } foo(1, 2, 3);

Output:

Number of arguments: 3 Second argument is: 2 Argument 0 is: 1 Argument 1 is: 2 Argument 2 is: 3

See also

func_get_arg(), func_num_args()

All PHP 8.5 built-in functions

Reference card built from the PHP manual page func_get_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.