老站長告訴你-PHP出現PHPNotice:Useofundefinedconstantxxxxx解決辦法
今天我用phpstudy調試程序,總是出現如下問題,但在阿里云服務器上用寶塔面板就沒有問題,困擾了我一天的時間,最終百度上找到一篇文章,
試了一下果然有效,分想給大家。
phpstudy2016的log報錯信息如下:
[Fri Jul 19 09:27:12.489860 2019] [:error] [pid 12400:tid 1820] [client ::1:4330] PHP Notice: Use of undefined constant name - assumed 'name' in D:\\phpStudy\\WWW\\tushuguan\\chklogin.php on line 8, referer: http://localhost:90/login.php
[Fri Jul 19 09:27:12.489860 2019] [:error] [pid 12400:tid 1820] [client ::1:4330] PHP Notice: Use of undefined constant pwd - assumed 'pwd' in D:\\phpStudy\\WWW\\tushuguan\\chklogin.php on line 9, referer: http://localhost:90/login.php
百度后得知這些是 PHP 的提示而非報錯,PHP 本身不需要事先聲明變量即可直接使用,但是對未聲明變量會有提示。一般作為正式的網站會把提示關掉的,甚至連錯誤信息也被關掉。
修改方法如下:
修改php.ini
將
error_reporting = E_ALL
改為
error_reporting = E_ALL & ~E_NOTICE