[固定] PHP Warning: Use of undefined constant (this will throw an Error in a future version of PHP)

簡單修復錯誤的教程“PHP Warning: Use of undefined constant (this will throw an Error in a future version of PHP)“。

PHP 7.2的 & PHP 7.3的 帶來更多的穩定性、靈活性和許多新功能,這 舊經, 插入-沙 害怕 WordPress 他們不再完全消化它們。

當您決定將您的服務器從 PHP 5.x 升級到 PHP 7.2 或 PHP 7.3 時,您還需要考慮一些代碼兼容性問題。 否則,您可能會遇到如下錯誤:

 PHP message: PHP Warning: Use of undefined constant CONSTANT - assumed 'CONSTANT' (this will throw an Error in a future version of PHP)

每次出現此錯誤消息 PHP代碼 找到一個未定義的常量。 適用於所有版本 PHP 7.2的PHP 7.3的.

[固定] PHP Warning: Use of undefined constant (this will throw an Error in a future version of PHP)

例如,如果我們有:

 echo $_POST[email]; 

// 持續的 ”mail” 必須定義,代碼如下所示:

echo $_POST["email"];

保存後報錯“PHP Warning: Use of undefined constant (this will throw an Error in a future version of PHP)“ 會消失。

如果您忘記將“$”在變量名前。

PHP升級後可能出現的其他錯誤

語法錯誤:較新版本的 PHP 引入了語言語法的更改,為 PHP 5.x 編寫的代碼可能與較新版本不兼容。 在升級之前檢查和更新任何語法錯誤很重要。

過時或被取代的功能: PHP 5.x 中使用的某些功能或特性可能在 PHP 7.x 中不再可用或可能被其他功能或特性取代。 您需要在代碼中識別並替換這些函數以確保兼容性。

數據類型問題: PHP 7.x 引入了更嚴格的數據類型處理。 因此,在依賴隱式或強制數據類型的代碼中可能會出現某些錯誤。 建議您仔細檢查數據類型並進行相應的管理。

減值錯誤:PHP 7.x 可能會刪除或棄用某些已棄用的功能或特性。 重要的是檢查這些已棄用的項目並將其替換為推薦的替代品。

作為科技愛好者,我從2006年開始在StealthSettings.com上愉快地撰寫文章。我在操作系統方面有豐富的經驗,包括macOS、Windows和Linux,還熟悉編程語言和博客平台(WordPress),以及在線商店平台(WooCommerce、Magento、PrestaShop)。

如何 » 教程和 IT 新聞 » [固定] PHP Warning: Use of undefined constant (this will throw an Error in a future version of PHP)
發表評論