關(guān)于PHP中變量未定義的提示

在家里電腦上自己做的項(xiàng)目,移到外網(wǎng)上時(shí)出現(xiàn)大量如下提示:

Notice: Use of undefined constant values - assumed 'values' inD:\wamp\www\yp\index.phpon line19

Notice: Use of undefined constant values - assumed 'values' inD:\wamp\www\yp\index.phpon line19

Notice: Use of undefined constant values - assumed 'values' inD:\wamp\www\yp\index.phpon line19

Notice: Use of undefined constant values - assumed 'values' inD:\wamp\www\yp\index.phpon line19

Notice: Use of undefined constant values - assumed 'values' inD:\wamp\www\yp\index.phpon line19

Notice: Use of undefined constant values - assumed 'values' inD:\wamp\www\yp\index.phpon line19

Notice: Use of undefined constant title - assumed 'title' inD:\wamp\www\yp\index.phpon line32

Notice: Use of undefined constant id - assumed 'id' inD:\wamp\www\yp\index.phpon line32

Notice: Use of undefined constant title - assumed 'title' inD:\wamp\www\yp\index.phpon line32

Notice: Use of undefined constant id - assumed 'id' inD:\wamp\www\yp\index.phpon line32

Notice: Use of undefined constant title - assumed 'title' inD:\wamp\www\yp\index.phpon line40

猛的一看,有點(diǎn)懵了,本來(lái)調(diào)試的好好的,怎么會(huì)突然出現(xiàn)錯(cuò)誤?

翻譯了下提示的意思,才明白原來(lái)PHP中允許中變量不經(jīng)過(guò)聲明而直接使用,但是如果設(shè)置了error_reporting后所有錯(cuò)誤全顯示的話,就會(huì)就出現(xiàn)提示,所以我們?cè)趯?xiě)代碼時(shí)最好養(yǎng)成習(xí)慣,變量使用前最好先聲明

解決方案自然是設(shè)置下error_reporting打開(kāi)php.ini將error_reporting = E_ALL 后面加上 & ~E_NOTICE

或者在全局配置文件里寫(xiě)error_reporting(0)

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容