2012年2月14日 星期二

PHP 出现Notice: Use of undefined constant 的解决方案

資料來源:http://www.sanywork.com/20090727612.html


進入網站會出現大量類似下面的提示,但是可以正常顯示和運行
Notice: Use of undefined constant ctbTitle - assumed 『ctbTitle' in d:\ctb1.5\ctb\include\config.php on line 23…


答案:這些是 PHP 的提示而非報錯,PHP 本身不需要事先聲明變量即可直接使用,但是對未聲明變量會有提示。一般作為正式的網站會把提示關掉的,甚至連錯誤信息也被關掉
關閉 PHP 提示的方法
搜索php.ini:
error_reporting = E_ALL
改為:
error_reporting = E_ALL & ~E_NOTIC