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

How to customize error page in yii2?

青灯夜游
Release: 2020-08-17 14:46:44
Original
3830 people have browsed it

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>
Copy after login

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

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

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template