函数参数前的三个点代表什么? [英] What do the three dots before a function argument represent?
本文介绍了函数参数前的三个点代表什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用Laravel 5.3,在其中一个功能中,我发现 代码:
I was working with Laravel 5.3 and in one of the functions, I found this piece of code:
public function handle($request, Closure $next, ...$guards)
{
$this->authenticate($guards);
return $next($request);
}
代码来自\Illuminate\Auth\Middleware\Authenticate::class
.
$guards
变量之前的那三个点是什么?
What are those 3 dots before $guards
variable?
推荐答案
它表示可能存在可变数量的参数.
It indicates that there may be a variable number of arguments.
当调用函数的参数超过3个时,$next
之后的所有参数都将添加到$guards
数组中.
When the function is called with more than 3 arguments, all the arguments after $next
will be added to the $guards
array.
您可以在此处上阅读有关内容.
You can read about it here.
这篇关于函数参数前的三个点代表什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文