Zend:使用参数重定向到操作 [英] Zend: Redirect to Action with parameters

查看:31
本文介绍了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:使用参数重定向到操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆