Zend: Redirect to Action with parameters(Zend:使用参数重定向到操作)
问题描述
我正在使用 zend 框架.我正在使用以下语句重定向到另一个操作.
I am using zend framework. I am using the following statement to redirect to another action.
$this->_helper->redirector('some_action');
以上语句运行良好,并且调用了some_action".现在我想像这样将一些参数传递给some_action".
Above statement is working perfectly and 'some_action' is called. Now I want to pass some parameters to 'some_action' like this.
some_action?uname=username&umail=username@example.com
以及如何在被调用的动作中获取参数.通常我们这样做:
And how to get parameters in called action. Usually we do like this:
$userName = $_REQUEST['uname'];
$usermail = $_REQUEST['umail'];
如何执行此操作?请示例代码.谢谢
How to perform this? Example code please. Thanks
推荐答案
使用 Zend_Controller_Action::redirect() 方法(它只是传递到 Sarfraz 的辅助方法)
Use the Zend_Controller_Action::redirect() method (which just passes through to Sarfraz's helper method)
$this->redirect('/module/controller/action/username/robin/email/robin@example.com');
注意:_redirect() 方法自 Zend Framework 1.7 起已弃用.改用 redirect().
Note: _redirect() method is deprecated as of Zend Framework 1.7. Use redirect() instead.
然后在调用的操作中:
$username = $this->_getParam('username');
$email = $this->_getParam('email');
_getParam() 接受第二个可选参数,如果未找到该参数,该参数将设置为该变量作为默认值.
_getParam() takes a second optional argument which is set to the variable as a default if the parameter isn't found.
这篇关于Zend:使用参数重定向到操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Zend:使用参数重定向到操作
基础教程推荐
- 在PHP中根据W3C规范Unicode 2022-01-01
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
- 如何在 Laravel 中使用 React Router? 2022-01-01
- PHP 类:全局变量作为类中的属性 2021-01-01
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
- 如何替换eregi() 2022-01-01
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
