Home  >  Article  >  PHP Framework  >  Yii2 implements custom error page

Yii2 implements custom error page

王林
王林Original
2020-02-19 11:28:532923browse

Yii2 implements custom error page

In the Yii2 version of the advanced template environment: How to set up a 404 custom page.

1. config/main.php file

'errorHandler' => [
'errorAction' => 'site/error',
 ],

Recommended related articles and tutorials: yii framework

2. views/site/error.php

<?php
$this->context->layout = false; //不使用布局,或者改为自己所需要使用的布局?>
<div class="site-error">
    <h1>404</h1>
</div>

For more programming-related content, please pay attention to the Programming Introduction column on the php Chinese website!

The above is the detailed content of Yii2 implements custom error page. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn