我想知道是否有人可能知道PHP 5.6.x及更高版本 ...
运算符的替代品(或者我相信它的splat运算符) .
我目前在PHP 7版本中所做的是:
$this->callAction(
...explode('@', $this->routes["authControllers"][$this->routes["uri"][$uri]])
);
callAction()
函数需要2个参数 callAction($controller, $action)
,但现在我需要将代码降级到PHP 5.4.17 .
2 回答
虽然splat运算符
...
类似于call_user_func_array()
:我认为传递必需的参数会更有意义:
我认为等效的PHP5代码将是
call_user_func_array(array($this,'callAction'),(explode('@', $this->routes["authControllers"][$this->routes["uri"][$uri]])));
编辑:但是如果callAction总是采用2个参数,你可以这样做
但如果是这样的话,idk为什么php7代码与
...
困扰,我认为这是为了可变数量的参数? (就像call_user_func_array是for . 对于一个带有可变数量参数的函数的例子,参见var_dump
)