func_get_args() Skips Variadic¶
<?php
function foo($a, ...$arg) {
print_r(func_get_args());
print_r($arg);
print_r($a);
}
function goo(...$arg) {
print_r(func_get_args());
print_r($arg);
}
foo(...[ 'b' => 2, 'a' => 1,'d' => 3]);
print PHP_EOL;
print PHP_EOL;
goo(...[ 'b' => 2, 'a' => 1,'d' => 3]);
func_get_args() does not provide the variadic argument, when there is one. It is simply omitted.
func_get_args() lists only the declared parameters, with their position, rather than their name.
func_get_args() is the traditional way to hand arbitrary number of arguments, and with this difference of behavior related to variadic, it provides a different set of features.
Nowadays, 23% of PHP applications use this feature.
See Also¶
PHP Features¶
Last updated: 14 July 2026