Zend Framework:如何故意抛出404错误?

And*_*rew 27 zend-framework http-status-code-404

我想故意在我的Zend Framework应用程序中的一个控制器中导致404错误.我怎样才能做到这一点?

Wou*_*elo 52

重定向到404将是:

throw new Zend_Controller_Action_Exception('Your message here', 404);
Run Code Online (Sandbox Code Playgroud)

或者没有异常:

$this->_response->clearBody();
$this->_response->clearHeaders();
$this->_response->setHttpResponseCode(404);
Run Code Online (Sandbox Code Playgroud)