我想知道是否有人知道 PHP 5.6.x 及更高版本的替代方案...
运算符(或 splat 运算符,我相信它被称为)。
我目前在 PHP 7 版本中所做的是:
$this->callAction(
...explode('@', $this->routes["authControllers"][$this->routes["uri"][$uri]])
);
The callAction()
函数有 2 个参数callAction($controller, $action)
但现在我需要将代码降级到 PHP 5.4.17。
虽然 splat 运算符...
类似于call_user_func_array()
:
call_user_func_array(array($this,'callAction'),
explode('@', $this->routes["authControllers"][$this->routes["uri"][$uri]]));
我认为传递所需的参数会更有意义:
list($controller, $action) = explode('@', $this->routes["authControllers"][$this->routes["uri"][$uri]]);
$this->callAction($controller, $action);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)