本文總結了zend framework重定向的方法。分享給大家供大家參考,具體如下:
一. render
不指定render
結果: {當前Module}/{當前Controller}/{當前Action}.phtml
$this->render('bar'); 結果: {當前Module}/{當前Controller}/bar.phtml
二. forward
$this->_forward('bar'); 結果: {當前Module}/{當前Controller}/bar
$this->_forward('bar', 'foo'); 結果: {當前Module}/foo/bar
$this->_forward('bar', 'foo', 'hoge'); 結果: hoge/foo/bar
$params = array( 'a' => '1', 'b' => '2');$this->_forward('bar', 'foo', 'hoge', $params); 結果: /hoge/foo/bar/a/1/b/2
三. redirect
$this->_redirect('/hoge'); 結果: /hoge
$this->_redirect('/hoge/foo'); 結果: /hoge/foo
$this->_redirect('/hoge/foo/bar'); 結果: /hoge/foo/bar
$this->_redirect('http://localhost/hoge/foo/bar'); 結果: http://localhost/hoge/foo/bar
$this->_redirect('http://localhost/hoge/foo/bar?a=1&b=2'); 結果: http://localhost/hoge/foo/bar?a=1&b=2
四. 特殊情況
不使用 layout
結果:
$this->_helper->layout()->disableLayout();
不使用 view
結果:
$this->_helper->viewRenderer->setNoRender();















