1. First go to the frontend\config folder of the Yii framework. There is a main.php file in it. Open it for editing and modify the controller name and method name:
2. Then go to the controllers controller and add the error method in the controller code.
3. Finally, create your view on layer V (here is error.php):
<?php use yii\helpers\Html; $this->title = $name; $this->context->layout = false; //不使用布局,或者改為自己所需要使用的布局 ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gbk" /> <title>這個.. 頁面沒有找到!!!_SJ5D.COM</title> <style type="text/css"> body{ margin:0; padding:0; background:#efefef; font-family:Georgia, Times, Verdana, Geneva, Arial, Helvetica, sans-serif; } div#mother{ margin:0 auto; width:943px; height:572px; position:relative; } div#errorBox{ background: url(/404_bg.png) no-repeat top left;width:943px; height:572px;margin:auto;} div#errorText{ color:#39351e; padding:146px 0 0 446px } div#errorText p{ width:303px; font-size:14px; line-height:26px; } div.link{ /*background:#f90;*/ height:50px; width:145px; float:left; } div#home{ margin:20px 0 0 444px;} div#contact{ margin:20px 0 0 25px;} h1{ font-size:40px; margin-bottom:35px; } </style> </head> <body> <div id="mother"> <div id="errorBox"> <div id="errorText"> <h1>Sorry..頁面沒有找到!</h1> <p> 似乎你所尋找的網(wǎng)頁已移動或丟失了。 <p>或者也許你只是鍵入錯誤了一些東西。</p> 請不要擔心,這沒事。如果該資源對你很重要,請與管理員聯(lián)系。 </p> <p> 火星不太安全,我可以免費送你回地球 </p> </div> <a href="http://www.baidu.com" title="返回SJ5D首頁"> <div class="link" id="home"></div> </a> <a href="http://www.aliyun.com" title="聯(lián)系管理員"> <div class="link" id="contact"></div> </a> </div> </div> </body> </html>
php Chinese website, a lot of are free Yii introductory tutorial, welcome to learn online!
The above is the detailed content of How does yii return 404. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

PHP Tips: Quickly implement the function of returning to the previous page. In web development, we often encounter the need to implement the function of returning to the previous page. Such operations can improve the user experience and make it easier for users to navigate between web pages. In PHP, we can achieve this function through some simple code. This article will introduce how to quickly implement the function of returning to the previous page and provide specific PHP code examples. In PHP, we can use $_SERVER['HTTP_REFERER'] to get the URL of the previous page

In the current information age, big data, artificial intelligence, cloud computing and other technologies have become the focus of major enterprises. Among these technologies, graphics card rendering technology, as a high-performance graphics processing technology, has received more and more attention. Graphics card rendering technology is widely used in game development, film and television special effects, engineering modeling and other fields. For developers, choosing a framework that suits their projects is a very important decision. Among current languages, PHP is a very dynamic language. Some excellent PHP frameworks such as Yii2, Ph

The Yii framework is an open source PHP Web application framework that provides numerous tools and components to simplify the process of Web application development, of which data query is one of the important components. In the Yii framework, we can use SQL-like syntax to access the database to query and manipulate data efficiently. The query builder of the Yii framework mainly includes the following types: ActiveRecord query, QueryBuilder query, command query and original SQL query

MySQL is a widely used relational database management system for storing and managing data. When we want to insert new data into a database table, we usually use the INSERT statement. In MySQL, when the INSERT statement is executed to successfully insert data, a result will be returned, which is the result of the insertion operation. In this article, we will discuss in detail the results returned by MySQL after inserting data and provide some specific code examples. 1. The result returned after inserting data is in MySQL. When successfully executed

As the demand for web applications continues to grow, developers have more and more choices in choosing development frameworks. Symfony and Yii2 are two popular PHP frameworks. They both have powerful functions and performance, but when faced with the need to develop large-scale web applications, which framework is more suitable? Next we will conduct a comparative analysis of Symphony and Yii2 to help you make a better choice. Basic Overview Symphony is an open source web application framework written in PHP and is built on

With the continuous development of cloud computing technology, data backup has become something that every enterprise must do. In this context, it is particularly important to develop a highly available cloud backup system. The PHP framework Yii is a powerful framework that can help developers quickly build high-performance web applications. The following will introduce how to use the Yii framework to develop a highly available cloud backup system. Designing the database model In the Yii framework, the database model is a very important part. Because the data backup system requires a lot of tables and relationships

The main differences between Laravel and Yii are design concepts, functional characteristics and usage scenarios. 1.Laravel focuses on the simplicity and pleasure of development, and provides rich functions such as EloquentORM and Artisan tools, suitable for rapid development and beginners. 2.Yii emphasizes performance and efficiency, is suitable for high-load applications, and provides efficient ActiveRecord and cache systems, but has a steep learning curve.

How to open a 404 website: 1. Choose a browser according to your preference; 2. You need to know the URL address of a 404 website, or search for "404 website list" or "random URL generator" in the search engine to find The addresses of some 404 websites; 3. Enter the address in the address bar of the browser, and then press the Enter key. The browser will try to connect to the address and return a 404 error page; 4. Before opening the 404 website, make sure The computer has the latest anti-virus software installed, and the browser's security settings are turned on.
