What do the three dots before a function argument represent?

后端 未结 1 673
南旧
南旧 2020-12-07 00:34

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)
{
    $th         


        
相关标签:
1条回答
  • 2020-12-07 01:18

    It indicates that there may be a variable number of arguments.

    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.

    0 讨论(0)
提交回复
热议问题