站长资讯网
最全最丰富的资讯网站

yii 开启错误提示的方法

yii 开启错误提示的方法

在使用YII框架做开发的时候,可能遇到错误你找了半天都不知道错误出在哪里,如果开启了错误信息提示,那么很明显的就能知道错在什么位置了。

但是我们最好把错误信息放在index-test.php下访问的时候提示,而不是放在访问index.php的时候提示,我们要如何处理呢?

首先我们要现在index-test.php中打开错误信息提示,需要加入以下两行代码

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

然后找到config下的main.php中的以下代码

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

但是我们只需要将代码缩减一下,放在test.php下即可,缩减后的代码如下

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

但是,这段代码也不是什么位置都可以放的哦,一定要放在'components'=>array()这个数组里面才行的,接下来就访问index.php以及index-test.php看看效果吧

相关文章教程推荐:yii教程

赞(0)
分享到: 更多 (0)