PHP 5.4.17 alternative for the “… operator”

前端 未结 2 1346
耶瑟儿~
耶瑟儿~ 2021-01-25 09:55

I was wondering if someone may know an alternative to the PHP 5.6.x and higher ... operator (or splat operator I believe its called).

What i\'m currently do

2条回答
  •  清酒与你
    2021-01-25 10:49

    Though the splat operator ... is similar to call_user_func_array():

    call_user_func_array(array($this,'callAction'),
                         explode('@', $this->routes["authControllers"][$this->routes["uri"][$uri]]));
    

    I think it would make more sense to pass the required arguments:

    list($controller, $action) = explode('@', $this->routes["authControllers"][$this->routes["uri"][$uri]]);
    $this->callAction($controller, $action);
    

提交回复
热议问题