参考链接

Example 1

1
2
3
4
5
6
7
8
9
10
11
<?php
function sum(...$numbers) {
$acc = 0;
foreach ($numbers as $n) {
$acc += $n;
}
return $acc;
}

echo sum(1, 2, 3, 4);
?>
1
10

Example 2

1
2
3
4
5
6
7
8
9
10
<?php
function add($a, $b) {
return $a + $b;
}

echo add(...[1, 2])."\n";

$a = [1, 2];
echo add(...$a);
?>
1
2
3
3