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);
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', // ), ), ),
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', ), ), ),
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!