本文整理汇总了PHP中ErrorPage::index方法的典型用法代码示例。如果您正苦于以下问题:PHP ErrorPage::index方法的具体用法?PHP ErrorPage::index怎么用?PHP ErrorPage::index使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ErrorPage
的用法示例。
在下文中一共展示了ErrorPage::index方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct()
{
$this->db = new DB();
$this->errors = new Errors();
$this->urlParse();
try {
if (file_exists(ROOT_DIR . '/core/controllers/' . $this->controller . '/' . $this->action . '.php')) {
include_once ROOT_DIR . '/core/controllers/' . $this->controller . '/' . $this->action . '.php';
} else {
throw new Exception('Страница не существует');
}
$controller = new Controller();
if (!method_exists($controller, 'index')) {
throw new Exception('Действие не существует');
}
$controller->errors = $this->errors->getErrors();
$controller->warnings = $this->errors->getWarnings();
$controller->params = $this->params;
$controller->index();
} catch (Exception $e) {
$this->errors->addError($e->getMessage());
header('HTTP/1.0 404 Not Found');
try {
if (file_exists(ROOT_DIR . '/core/controllers/error404/index.php')) {
include_once ROOT_DIR . '/core/controllers/error404/index.php';
} else {
throw new Exception('Не найден шаблон вывода ошибок');
}
$controller = new ErrorPage();
$controller->errors = $this->errors->getErrors();
$controller->warnings = $this->errors->getWarnings();
$controller->index();
} catch (Exception $e) {
$this->errors->addWarning($e->getMessage());
$this->errors->showErrorPage();
die;
}
}
}