[固定] 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 可能会删除或弃用某些已弃用的功能或特性。 重要的是检查这些已弃用的项目并将其替换为推荐的替代品。

对技术充满热情,我很高兴写 StealthSettings.com 自 2006 年起。您会找到我撰写的有关操作系统的文章 Windows, Linux, macOS,还涉及网络平台,例如 WordPress 对 WooCommerce

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

发表评论