是否可以为 zend 框架提供自定义 500 错误页面?我的意思是 ErrorController 中的某些内容...如果您有 500 错误,请查看自定义视图渲染。
<?php
class ErrorController extends Zend_Controller_Action
{
private $_notifier;
private $_error;
private $_environment;
public function init()
{
parent::init();
$this->_error = $this->_getParam('error_handler');
}
public function errorAction()
{
switch ($this->_error->type) {
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
$this->getResponse()->setHttpResponseCode(404);
$this->view->message = 'Page not found';
break;
default:
//Doesn't work
$this->renderScript('error/500.phtml');
$this->getResponse()->setHttpResponseCode(500);
break;
}
}
}