Ответ 1
Перенаправление на 404 будет:
throw new Zend_Controller_Action_Exception('Your message here', 404);
Или без исключения:
$this->_response->clearBody();
$this->_response->clearHeaders();
$this->_response->setHttpResponseCode(404);
Я хотел бы намеренно вызвать ошибку 404 в одном из контроллеров моего приложения Zend Framework. Как я могу это сделать?
Перенаправление на 404 будет:
throw new Zend_Controller_Action_Exception('Your message here', 404);
Или без исключения:
$this->_response->clearBody();
$this->_response->clearHeaders();
$this->_response->setHttpResponseCode(404);
Вы всегда можете установить код ответа вручную, не выбрасывая никаких исключений.
$this->_response->clearBody();
$this->_response->clearHeaders();
$this->_response->setHttpResponseCode(404);