PHP運(yùn)行出現(xiàn)Notice : Use of undefined constant 的完美解決方案分享
更新時(shí)間:2012年03月05日 11:46:43 作者:
今天修改公司的網(wǎng)站,提示Notice : Use of undefined constant ,通過(guò)下面的方法解決了,最好是error_reporting(0);不需要更改配置
Notice: Use of undefined constant ALL_PS - assumed 'ALL_PS' in E:\Server\vhosts\www.lvtao.net\global.php on line 50
Notice: Undefined index: EaseTemplateVer in E:\Server\vhosts\www.lvtao.net\libs\template.core.php on line 51
Notice: Use of undefined constant uid - assumed 'uid' in E:\Server\vhosts\www.lvtao.net\global.php on line 54
Notice: Undefined index: uid in E:\Server\vhosts\www.lvtao.net\global.php on line 54
Notice: Use of undefined constant cuid - assumed 'cuid' in E:\Server\vhosts\www.lvtao.net\global.php on line 55
Notice: Undefined index: cuid in E:\Server\vhosts\www.lvtao.net\global.php on line 55
Notice: Use of undefined constant shell - assumed 'shell' in E:\Server\vhosts\www.lvtao.net\global.php on line 56
Notice: Undefined index: shell in E:\Server\vhosts\www.lvtao.net\global.php on line 56
Notice: Use of undefined constant cshell - assumed 'cshell' in E:\Server\vhosts\www.lvtao.net\global.php on line 57
Notice: Undefined index: cshell in E:\Server\vhosts\www.lvtao.net\global.php on line 57
Notice: Use of undefined constant username - assumed 'username' in E:\Server\vhosts\www.lvtao.net\global.php on line 58
Notice: Undefined index: username in E:\Server\vhosts\www.lvtao.net\global.php on line 58
Notice: Use of undefined constant cusername - assumed 'cusername' in E:\Server\vhosts\www.lvtao.net\global.php on line 59
Notice: Undefined index: cusername in E:\Server\vhosts\www.lvtao.net\global.php on line 59
Notice: Use of undefined constant id - assumed 'id' in E:\Server\vhosts\www.lvtao.net\companyjob.php on line 10
Notice: Use of undefined constant id - assumed 'id' in E:\Server\vhosts\www.lvtao.net\companyjob.php on line 14
Notice: Use of undefined constant content - assumed 'content' in E:\Server\vhosts\www.lvtao.net\companyjob.php on line 16
Notice: Use of undefined constant content - assumed 'content' in E:\Server\vhosts\www.lvtao.net\companyjob.php on line 16
Notice: Use of undefined constant description - assumed 'description' in E:\Server\vhosts\www.lvtao.net\companyjob.php on line 17
Notice: Use of undefined constant description - assumed 'description' in E:\Server\vhosts\www.lvtao.net\companyjob.php on line 17
Notice: Use of undefined constant provinceid - assumed 'provinceid' in E:\Server\vhosts\www.lvtao.net\companyjob.php on line 18
Notice: Use of undefined constant cityid - assumed 'cityid' in E:\Server\vhosts\www.lvtao.net\companyjob.php on line 19
Notice: Use of undefined constant hy - assumed 'hy' in E:\Server\vhosts\www.lvtao.net\companyjob.php on line 20
Notice: Undefined variable: content in E:\Server\vhosts\www.lvtao.net\libs\template.core.php on line 557
進(jìn)入網(wǎng)站會(huì)出現(xiàn)大量類似下面的提示,但是可以正常顯示和運(yùn)行
Notice: Use of undefined constant ctbTitle - assumed 'ctbTitle' in d:\ctb1.5\ctb\include\config.php on line 23...
b答案:這些是 PHP 的提示而非報(bào)錯(cuò),PHP 本身不需要事先聲明變量即可直接使用,但是對(duì)未聲明變量會(huì)有提示。一般作為正式的網(wǎng)站會(huì)把提示關(guān)掉的,甚至連錯(cuò)誤信息也被關(guān)掉
關(guān)閉 PHP 提示的方法
搜索php.ini:
error_reporting = E_ALL
改為:
error_reporting = E_ALL & ~E_NOTICE
還有個(gè)不是辦法的辦法就是
在每個(gè)文件頭上加
error_reporting(0); 雖然不好弄但是可以解決問(wèn)題!?。。。?!這個(gè)比較好用
Notice: Undefined index: EaseTemplateVer in E:\Server\vhosts\www.lvtao.net\libs\template.core.php on line 51
Notice: Use of undefined constant uid - assumed 'uid' in E:\Server\vhosts\www.lvtao.net\global.php on line 54
Notice: Undefined index: uid in E:\Server\vhosts\www.lvtao.net\global.php on line 54
Notice: Use of undefined constant cuid - assumed 'cuid' in E:\Server\vhosts\www.lvtao.net\global.php on line 55
Notice: Undefined index: cuid in E:\Server\vhosts\www.lvtao.net\global.php on line 55
Notice: Use of undefined constant shell - assumed 'shell' in E:\Server\vhosts\www.lvtao.net\global.php on line 56
Notice: Undefined index: shell in E:\Server\vhosts\www.lvtao.net\global.php on line 56
Notice: Use of undefined constant cshell - assumed 'cshell' in E:\Server\vhosts\www.lvtao.net\global.php on line 57
Notice: Undefined index: cshell in E:\Server\vhosts\www.lvtao.net\global.php on line 57
Notice: Use of undefined constant username - assumed 'username' in E:\Server\vhosts\www.lvtao.net\global.php on line 58
Notice: Undefined index: username in E:\Server\vhosts\www.lvtao.net\global.php on line 58
Notice: Use of undefined constant cusername - assumed 'cusername' in E:\Server\vhosts\www.lvtao.net\global.php on line 59
Notice: Undefined index: cusername in E:\Server\vhosts\www.lvtao.net\global.php on line 59
Notice: Use of undefined constant id - assumed 'id' in E:\Server\vhosts\www.lvtao.net\companyjob.php on line 10
Notice: Use of undefined constant id - assumed 'id' in E:\Server\vhosts\www.lvtao.net\companyjob.php on line 14
Notice: Use of undefined constant content - assumed 'content' in E:\Server\vhosts\www.lvtao.net\companyjob.php on line 16
Notice: Use of undefined constant content - assumed 'content' in E:\Server\vhosts\www.lvtao.net\companyjob.php on line 16
Notice: Use of undefined constant description - assumed 'description' in E:\Server\vhosts\www.lvtao.net\companyjob.php on line 17
Notice: Use of undefined constant description - assumed 'description' in E:\Server\vhosts\www.lvtao.net\companyjob.php on line 17
Notice: Use of undefined constant provinceid - assumed 'provinceid' in E:\Server\vhosts\www.lvtao.net\companyjob.php on line 18
Notice: Use of undefined constant cityid - assumed 'cityid' in E:\Server\vhosts\www.lvtao.net\companyjob.php on line 19
Notice: Use of undefined constant hy - assumed 'hy' in E:\Server\vhosts\www.lvtao.net\companyjob.php on line 20
Notice: Undefined variable: content in E:\Server\vhosts\www.lvtao.net\libs\template.core.php on line 557
進(jìn)入網(wǎng)站會(huì)出現(xiàn)大量類似下面的提示,但是可以正常顯示和運(yùn)行
Notice: Use of undefined constant ctbTitle - assumed 'ctbTitle' in d:\ctb1.5\ctb\include\config.php on line 23...
b答案:這些是 PHP 的提示而非報(bào)錯(cuò),PHP 本身不需要事先聲明變量即可直接使用,但是對(duì)未聲明變量會(huì)有提示。一般作為正式的網(wǎng)站會(huì)把提示關(guān)掉的,甚至連錯(cuò)誤信息也被關(guān)掉
關(guān)閉 PHP 提示的方法
搜索php.ini:
error_reporting = E_ALL
改為:
error_reporting = E_ALL & ~E_NOTICE
還有個(gè)不是辦法的辦法就是
在每個(gè)文件頭上加
error_reporting(0); 雖然不好弄但是可以解決問(wèn)題!?。。。?!這個(gè)比較好用
您可能感興趣的文章:
- 淺談ThinkPHP中initialize和construct的區(qū)別
- ThinkPHP中類的構(gòu)造函數(shù)_construct()與_initialize()的區(qū)別詳解
- PHP正則替換函數(shù)preg_replace()報(bào)錯(cuò):Notice Use of undefined constant的解決方法分析
- php類中的$this,static,final,const,self這幾個(gè)關(guān)鍵字使用方法
- ThinkPHP中__initialize()和類的構(gòu)造函數(shù)__construct()用法分析
- 解析php中static,const與define的使用區(qū)別
- php面向?qū)ο笕ヂ?(十) final static const關(guān)鍵字的使用
- PHP const定義常量及global定義全局常量實(shí)例解析
相關(guān)文章
最新用php獲取谷歌PR值算法,附上php查詢PR值代碼示例
用php程序怎么獲取谷歌PR值,已經(jīng)有好幾個(gè)人問(wèn)我php查詢PR值怎么實(shí)現(xiàn)的,于是現(xiàn)在就把php查詢PR值法算法附上,大家可以直接使用下面的代碼去測(cè)試php查詢PR值2011-12-12php多進(jìn)程并發(fā)編程防止出現(xiàn)僵尸進(jìn)程的方法分析
這篇文章主要介紹了php多進(jìn)程并發(fā)編程防止出現(xiàn)僵尸進(jìn)程的方法,結(jié)合具體實(shí)例形式總結(jié)分析了php多進(jìn)程并發(fā)編程防止出現(xiàn)僵尸進(jìn)程相關(guān)操作技巧與注意事項(xiàng),需要的朋友可以參考下2020-02-02PHP array_multisort()函數(shù)的使用札記
array_multisort 對(duì)多個(gè)數(shù)組或多維數(shù)組進(jìn)行排序的函數(shù),需要的朋友可以參考下。2011-07-07PHP程序61條面向?qū)ο蠓治鲈O(shè)計(jì)的經(jīng)驗(yàn)小結(jié)
你不必嚴(yán)格遵守這些原則,違背它們也不會(huì)被處以宗教刑罰。但你應(yīng)當(dāng)把這些原則看成警鈴,若違背了其中的一條,那么警鈴就會(huì)響起 。 ----- Arthur J.Riel2008-11-11php中將html中的br換行符轉(zhuǎn)換為文本輸入中的換行符
PHP中的有個(gè)非常好的函數(shù):nl2br(),將文本框中的換行轉(zhuǎn)換為HTML頁(yè)面的<br />,但是如何實(shí)現(xiàn)將html中的<br />換行符轉(zhuǎn)換為文本框中的換行符呢2013-03-03