Cake PHP 重定向在 url 中带有参数

Cake PHP redirect with parameters in url(Cake PHP 重定向在 url 中带有参数)
本文介绍了Cake PHP 重定向在 url 中带有参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我有一个页面,我想重定向到它需要 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:val1param2: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 中带有参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)