問題描述
我有一個頁面,我想重定向到它需要 URL 中的參數:http://www.example.com/myController/myAction/param1:val1/param2:val2
我知道有一個用于重定向的 CakePHP 重定向函數,其工作方式如下:
$this->redirect(array("controller" => "myController",動作" =>"我的行動",$data_can_be_passed_here),$status, $exit);
如何使用上述函數添加我想要的參數作為 url 的一部分?
我認為可能還有另一個元素可以添加到數組中,以便我可以傳遞 param1:val1
和 param2:val2
.
任何幫助將不勝感激!
我不知道為什么我無法在 CakePHP 文檔中找到這個,但我終于找到了解決方案.我把它貼在這里以防其他人有同樣的問題.(如果有人知道這是在文檔中的哪個位置,也請貼出來,謝謝!)
重定向到 URL:
http://www.example.com/myController/myAction/param1:val1/param2:val2
您可以使用:
<塊引用>$this->redirect(array("controller" => "myController",動作" =>"我的行動",參數 1" =>"val1",參數 2" =>"val2",$data_can_be_passed_here),$狀態,$退出);
希望能幫到你!
I have a page that I want to redirect to that requires parameters in the URL: http://www.example.com/myController/myAction/param1:val1/param2:val2
I know that there is a CakePHP redirect function for redirecting that works as follows:
$this->redirect(array("controller" => "myController",
"action" => "myAction",
$data_can_be_passed_here),
$status, $exit);
How do I add the parameters that I want as part of the url using the above function?
I would think that there might be another element that I could add to array so that I can pass along param1:val1
and param2:val2
.
Any help would be greatly appreciated!
I do not know why I was not able to find this in the CakePHP documentation, but I did finally figure out the solution. I am posting it here in case anyone else has the same problem. (If someone knows where this is in the documentation please post it as well, thanks!)
To redirect to the URL:
http://www.example.com/myController/myAction/param1:val1/param2:val2
You can use:
$this->redirect(array("controller" => "myController", "action" => "myAction", "param1" => "val1", "param2" => "val2", $data_can_be_passed_here), $status, $exit);
Hope it helps!
這篇關于Cake PHP 重定向在 url 中帶有參數的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!