Home > PHP Framework > YII > How to enable error prompts in yii

How to enable error prompts in yii

藏色散人
Release: 2020-02-01 14:42:25
Original
4116 people have browsed it

How to enable error prompts in yii

When using the YII framework for development, you may encounter an error and you may not know where the error is after looking for it for a long time. If the error message prompt is turned on, it will be obvious. I know where the mistake is.

But we’d better put the error message when accessing index-test.php instead of prompting when accessing index.php. How should we deal with it?

First of all, we need to open the error message prompt in index-test.php. We need to add the following two lines of code

ini_set('display_errors', 'On');
error_reporting(E_ALL & ~E_NOTICE);
Copy after login

Then find the following code in main.php under config

'log'=>array(
'class'=>'CLogRouter',
'routes'=>array(
array(
'class'=>'CFileLogRoute',
'levels'=>'error, warning',
),
// uncomment the following to show log messages on web pages
// array(
// 'class'=>'CWebLogRoute',
// ),
),
),
Copy after login

But we only need to reduce the code and put it under test.php. The reduced code is as follows

'log'=>array(
'routes'=>array(
// uncomment the following to show log messages on web pages
array(
'class'=>'CWebLogRoute',
),
),
),
Copy after login

However, this code cannot be placed anywhere. , it must be placed in the array 'components'=>array(). Next, visit index.php and index-test.php to see the effect

Recommended related article tutorials:yii tutorial

The above is the detailed content of How to enable error prompts in yii. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
yii
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