找回密碼
 註冊
搜索
查看: 693|回復: 0

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

[複製鏈接]
發表於 2023-10-6 17:29:18 | 顯示全部樓層 |閱讀模式
 
Push to Facebook
問題:
  1. [06-Oct-2023 17:18:12 Asia/Taipei] 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
  2. [06-Oct-2023 17:18:12 Asia/Taipei] 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
  3. [06-Oct-2023 17:18:12 Asia/Taipei] 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
  4. [06-Oct-2023 17:18:12 Asia/Taipei] 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
  5. [06-Oct-2023 17:18:12 Asia/Taipei] 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
  6. [06-Oct-2023 17:18:12 Asia/Taipei] 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
  7. [06-Oct-2023 17:18:12 Asia/Taipei] 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
  8. [06-Oct-2023 17:18:12 Asia/Taipei] 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); 雖然不好弄但是可以解決問題.


 
您需要登錄後才可以回帖 登錄 | 註冊

本版積分規則

Archiver|手機版|小黑屋|TShopping

GMT+8, 2025-4-30 19:56 , Processed in 0.020830 second(s), 21 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

快速回復 返回頂部 返回列表