PHP7.4报错Warning: Use of undefined constant

PHP与SEO 思享 852浏览
摘要:
背景:主题改变了web环境,目前使用的是Pagoda Panel的PHP 7.4版本。结果发现404页报错,错误提示如下:。警告:在/xxx/xxx.phplonlin10.php中使用未定义的常量DESC假设的“DESC”改变了常量的书写格式。以前使用desc没有问题,但是更高的版本需要修改。添加“desc”类似于标准化字符串的书写。

背景:主题更换了web环境,目前使用的是宝塔面板的php7.4版本,结果发现404页面报错了,报错提示如下:

Warning: Use of undefined constant DESC - assumed 'DESC' (this will throw an Error in a future version of PHP) in /xxx/xxx.php on line 10

报错原因

php更改了常量的书写格式,之前使用DESC 没有问题,但是高版本需要修改加上'DESC' 类似于规范了是一个字符串的书写方式

找到提示错误的代码,加上英文的单引号或双引号即可

举例子:

原代码

$args = array(
		    'order'   => DESC
		);

修改为

$args = array(
		    'order'   => "DESC"
		);

推荐阅读

Function get_magic_quotes_gpc() is deprecated报错解决办法

在 PHP 7.4 及更高版本中, get_magic_quotes_gpc() 函数已被弃用。 This means that code using this function will raise a warning or error.以下是解决......

PHP提示:Warning: count():Parameter must be an array or an object that implements Countable

错误原因:PHP7.2以后,count()函数的参数无效时会抛出warning警告。...

PHP7.4 报错:Deprecated Functionality: implode(): Passing glue string after array is deprecated.

PHP7.4运行项目报错:Deprecated Functionality: implode(): Passing glue string after array is deprecated。只需交换 implode() 函数的两个参数!...