Zend Controller Action:_redirect()vs getHelper('Redirector') - > gotoUrl()

时间:2011-03-11 14:46:24

标签: zend-framework redirect zend-controller

我读过$this->getHelper('[helper_name]')$this->_helper->[helper_name]更可取。我无法找到任何文档是哪个更好/首选:$this->_redirect($url)$this->getHelper('Redirector')->gotoUrl($url)

1 个答案:

答案 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);
}