在使用YII框架做開(kāi)發(fā)的時(shí)候,可能遇到錯(cuò)誤你找了半天都不知道錯(cuò)誤出在哪里,如果開(kāi)啟了錯(cuò)誤信息提示,那么很明顯的就能知道錯(cuò)在什么位置了。
但是我們最好把錯(cuò)誤信息放在index-test.php下訪問(wèn)的時(shí)候提示,而不是放在訪問(wèn)index.php的時(shí)候提示,我們要如何處理呢?
首先我們要現(xiàn)在index-test.php中打開(kāi)錯(cuò)誤信息提示,需要加入以下兩行代碼
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()這個(gè)數(shù)組里面才行的,接下來(lái)就訪問(wèn)index.php以及index-test.php看看效果吧
相關(guān)文章教程推薦:yii教程