woff 發表於 2023-10-6 17:29:18

PHP7 運行出現Notice : Use of undefined constant 的解決方法

問題:
PHP Warning:Use of undefined constant page - assumed 'page' (this will throw an Error in a future version of PHP) in /home/pipe/public_html/includes/page.class.php on line 8
PHP Warning:Use of undefined constant pageft - assumed 'pageft' (this will throw an Error in a future version of PHP) in /home/pipe/public_html/includes/page.class.php on line 9
PHP Warning:Use of undefined constant ALL_PS - assumed 'ALL_PS' (this will throw an Error in a future version of PHP) in /home/pipe/public_html/modules/shopcart/admin/admin_global.php on line 8
PHP Warning:Use of undefined constant uid - assumed 'uid' (this will throw an Error in a future version of PHP) in /home/pipe/public_html/modules/shopcart/admin/admin_global.php on line 11
PHP Warning:Use of undefined constant shell - assumed 'shell' (this will throw an Error in a future version of PHP) in /home/pipe/public_html/modules/shopcart/admin/admin_global.php on line 12
PHP Warning:Use of undefined constant username - assumed 'username' (this will throw an Error in a future version of PHP) in /home/pipe/public_html/modules/shopcart/admin/includes/action.class.php on line 22
PHP Warning:Use of undefined constant passwd - assumed 'passwd' (this will throw an Error in a future version of PHP) in /home/pipe/public_html/modules/shopcart/admin/includes/action.class.php on line 22
PHP Warning:Use of undefined constant m_id - assumed 'm_id' (this will throw an Error in a future version of PHP) in /home/pipe/public_html/modules/shopcart/admin/includes/action.class.php on line 28問題描述;       進入網站會出現大量類似下面的提示,但是可以正常顯示和運行.最大的問題是LOG檔案占空間,沒多久就數十GB答案      這些是 PHP 的提示而非報錯,PHP 本身不需要事先宣告變數即可直接使用,但對未宣告變數會有提示。一般作為正式的網站會把提示關掉的,甚至連錯誤訊息也被關掉.關閉 PHP 提示的方法  搜尋php.ini:  error_reporting = E_ALL  改為:  error_reporting = E_ALL & ~E_NOTICE  還有個不是辦法的辦法就是  在每個文件頭上加  error_reporting(0); 雖然不好弄但是可以解決問題.
頁: [1]
查看完整版本: PHP7 運行出現Notice : Use of undefined constant 的解決方法