Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / PHP

func_get_args()

Inside a user function, func_get_args returns the current argument values in positional order, including modifications to bound parameters.

Version: PHP 8.4; repository runtime, production runtime not attested

Syntax

func_get_args(): array

Inside a user function, func_get_args returns the current argument values in positional order, including modifications to bound parameters. Trailing defaults that were not passed are omitted. A named argument that skips an earlier declared parameter fills that gap with its default; unknown named variadic arguments remain only in the variadic parameter. Calling it at global scope raises Error.

Signature

func_get_args(): array

Example output

[["x!"],[]]
[["A!","y"],{"tag":4}]
Error

Examples

<?php
function capture($a = "A", $b = "B", ...$more): array {
    $a .= "!";
    return [func_get_args(), $more];
}
echo json_encode(capture("x")), PHP_EOL;
echo json_encode(capture(b: "y", tag: 4)), PHP_EOL;
try { func_get_args(); } catch (Error $e) { echo get_class($e); }

Result

[["x!"],[]]
[["A!","y"],{"tag":4}]
Error

Sources