function sum(...$numbers) { $acc = 0; foreach( $numbers as $number ) { $acc += $number; } return $acc; } echo sum(1,2,3,4);
function sumNumber($a,$b ) { echo $a + $b; echo "\n"; } sumNumber(...[1,2]); $a = [1,2]; sumNumber(...$a);
本文来自博客园,作者:孙龙-程序员,转载请注明原文链接:https://www.cnblogs.com/sunlong88/articles/9364935.html