Variadic Are Typed And Defaulted¶
<?php
function foo($a, ...$arg /* = [] */) {
var_dump($arg);
// array()
}
foo(1);
?>
When using the ... operator, the argument is automatically typed and defaulted: it is typed with array, and its default value is the empty array [].
There can be a type added to the argument, and, with it, element element of the argument will be of this type. Yet, the argument itself is actually array.
See Also¶
PHP Features¶
Last updated: 14 July 2026