2017-06-21 11 views
0

誰かがPHP 5.6.x以降の演算子(または私が呼び出されたと思われるsplat演算子)の代わりを知っているのではないかと思っていました。私は現在、私のPHPで7バージョンをやって何"... operator"の代わりのPHP 5.4.17

は次のとおりです。

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

callAction()関数は、2つのパラメータcallAction($controller, $action)を取りますが、今、私はPHP 5.4.17にコードをダウングレードする必要があります。

+1

PHP 5.4はほぼ2年間サポートされておらず、結果として危険にさらされる危険があります。つまり、古いアプローチでは代わりにhttp://php.net/func_get_argsを使用していました。 – ceejayoz

+0

ありがとう、私はfunc_get_argsを見ていきます。 配列に展開し、 '0'と' 1'を渡すか、 'call_user_func_arrayを使用してください。/ –

+1

これは、あなたのローカルサーバーを更新するものではありません。 () 'を返します。 – AbraCadaver

答えて

0

スプラットオペレータ...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); 
+0

あなたの返信ありがとう –

0

私は同等のPHP5のコードがcall_user_func_array(array($this,'callAction'),(explode('@', $this->routes["authControllers"][$this->routes["uri"][$uri]])));

編集だと思う。しかしcallActionは常に正確に2つの引数を取る場合、あなただけの

$args=explode('@',$this->routes["authControllers"][$this->routes["uri"][$uri]])); 
$this->callAction($args[0],$args[1]); 

を行うことができますが、場合厥、なぜPHP7をIDKの場合コードは...で気になります。私はそれがさまざまな議論のためだと思いましたか? (call_user_func_array等のためである可変個の引数を取る関数の例については、var_dumpを参照してください。)

+0

あなたの返信ありがとう –

関連する問題