Zend Framework: How to intentionally throw a 404 error?

强颜欢笑 提交于 2019-12-02 18:56:54

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);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!