我读过$this->getHelper('[helper_name]')
比$this->_helper->[helper_name]
更可取。我无法找到任何文档是哪个更好/首选:$this->_redirect($url)
或$this->getHelper('Redirector')->gotoUrl($url)
。
答案 0 :(得分:5)
使用适合你的任何人,他们做同样的事情:
/**
* Redirect to another URL
*
* Proxies to {@link Zend_Controller_Action_Helper_Redirector::gotoUrl()}.
*
* @param string $url
* @param array $options Options to be used when redirecting
* @return void
*/
protected function _redirect($url, array $options = array())
{
$this->_helper->redirector->gotoUrl($url, $options);
}