开发者

Zend Framework: How to intentionally throw a 404 error?

I would like to intentionally cause a 404 error within one of the controllers in my Zend Framework application. How ca开发者_Python百科n I do this?


A redirect to a 404 would be:

throw new Zend_Controller_Action_Exception('Your message here', 404);

Or without Exception:

$this->_response->clearBody();
$this->_response->clearHeaders();
$this->_response->setHttpResponseCode(404);


You can always set the response code manually, without throwing any exceptions.

$this->_response->clearBody();
$this->_response->clearHeaders();
$this->_response->setHttpResponseCode(404);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜