如何使用 redirect() 设置查询参数 [英] How to set query parameter with redirect()
本文介绍了如何使用 redirect() 设置查询参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在重定向时设置查询参数.我试过这个:
I would like to set a query parameter when redirecting. I tried this:
$this->redirect()->toRoute('login/default', array('action' => 'forgotPassword', 'foo' => 'bar'));
它重定向到:
/login/forgotPassword
而不是我想重定向的位置:
Instead of where I would like to redirect which is:
/login/forgotPassword?foo=bar
推荐答案
查询参数属于 URL-Methods 的第三个参数.
The query parameter belongs to the third parameter of the URL-Methods.
$this->redirect()->toRoute(
'login/default',
array(
'action' => 'forgotPassword'
),
array( 'query' => array(
'foo' => 'bar'
))
)
这篇关于如何使用 redirect() 设置查询参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文