在家里電腦上自己做的項(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è)趯懘a時(shí)最好養(yǎng)成習(xí)慣糯累,變量使用前最好先聲明
解決方案自然是設(shè)置下error_reporting打開(kāi)php.ini將error_reporting = E_ALL 后面加上 & ~E_NOTICE
或者在全局配置文件里寫error_reporting(0)