'site/error'," statement to call."/> 'site/error'," statement to call.">

Home  >  Article  >  PHP Framework  >  How to customize error page in yii2?

How to customize error page in yii2?

青灯夜游
青灯夜游Original
2020-08-17 14:46:443810browse

yii2 How to customize the error page: 1. Set the style of the error page in "views/site/error.php"; 2. In "config/main.php", modify the configuration file and use "'errorAction'=>'site/error'," statement is called.

How to customize error page in yii2?

In the advanced template environment of the Yii2 version, customize the 404 error page:

1, views/ site/error.php, set the error page style

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

2. Modify the application configuration file: config/main.php

&#39;errorHandler&#39; => [
&#39;errorAction&#39; => &#39;site/error&#39;,
 ],

related Recommended article tutorials: "yii Framework Tutorial", "PHP Tutorial"

The above is the detailed content of How to customize error page in yii2?. 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