PHP 错误 Unparenthesized `a ? b : c ? d : e` is not supported

最近在一个新的服务器上测试一些老代码的时候得到了类似上面的错误:

[Thu Apr 25 07:37:34.139768 2024] [php:error] [pid 691410] [client 192.168.1.229:57183] PHP Fatal error:  Unparenthesized `a ? b : c ? d : e` is not supported. Use either `(a ? b : c) ? d : e` or `a ? b : (c ? d : e)` in /var/www/html/massnet/wp-content/themes/enfold/functions-enfold.php on line 265
[Thu Apr 25 07:37:35.883933 2024] [php:error] [pid 691415] [client 192.168.1.229:57182] PHP Fatal error:  Unparenthesized `a ? b : c ? d : e` is not supported. Use either `(a ? b : c) ? d : e` or `a ? b : (c ? d : e)` in /var/www/html/massnet/wp-content/themes/enfold/functions-enfold.php on line 265
[Thu Apr 25 07:37:36.665729 2024] [php:error] [pid 691411] [client 192.168.1.229:57189] PHP Fatal error:  Unparenthesized `a ? b : c ? d : e` is not supported. Use either `(a ? b : c) ? d : e` or `a ? b : (c ? d : e)` in /var/www/html/massnet/wp-content/themes/enfold/functions-enfold.php on line 265
[Thu Apr 25 07:37:36.864684 2024] [php:error] [pid 691412] [client 192.168.1.229:57191] PHP Fatal error:  Unparenthesized `a ? b : c ? d : e` is not supported. Use either `(a ? b : c) ? d : e` or `a ? b : (c ? d : e)` in /var/www/html/massnet/wp-content/themes/enfold/functions-enfold.php on line 265
[Thu Apr 25 07:37:37.059653 2024] [php:error] [pid 691413] [client 192.168.1.229:57193] PHP Fatal error:  Unparenthesized `a ? b : c ? d : e` is not supported. Use either `(a ? b : c) ? d : e` or `a ? b : (c ? d : e)` in /var/www/html/massnet/wp-content/themes/enfold/functions-enfold.php on line 265
[Thu Apr 25 07:37:37.266231 2024] [php:error] [pid 691414] [client 192.168.1.229:57195] PHP Fatal error:  Unparenthesized `a ? b : c ? d : e` is not supported. Use either `(a ? b : c) ? d : e` or `a ? b : (c ? d : e)` in /var/www/html/massnet/wp-content/themes/enfold/functions-enfold.php on line 265
[Thu Apr 25 07:37:37.474902 2024] [php:error] [pid 691410] [client 192.168.1.229:57197] PHP Fatal error:  Unparenthesized `a ? b : c ? d : e` is not supported. Use either `(a ? b : c) ? d : e` or `a ? b : (c ? d : e)` in /var/www/html/massnet/wp-content/themes/enfold/functions-enfold.php on line 265
~                                                                                                                                                                                                                                                                                                             

错误原因

a ? b : c 这是一种常见的三元运算符 意思是如果 a成立那么结果就返回b 否则返回c

a ? b : c ? d : e 当你这么写时 程序就会有多种理解了

一种是 (a ? b : c) ? d : e 把前面的当做了一个整体

另一种是 a ? b : (c ? d : e) 把后面的当做了一个整体

在 PHP 8 中,这种错误被标记为严重错误。

出现上面的原因是 PHP 8 升级的问题。

这个问题出现在我们 WP 安装的插件上,为了避免这个问题,要么需要更新插件的版本,要么就不要更新 PHP 的版本。

感觉 PHP 8 升级后,不少插件的作者都没有来得及更新,也引起了不少的问题。

PHP 错误 Unparenthesized `a ? b : c ? d : e` is not supported. Use eithe - PHP - iSharkFly最近在一个新的服务器上测试一些老代码的时候得到了类似上面的错误: [Thu Apr 25 07:37:34.139768 2024] [php:error] [pid 691410] [client 192.168.1.229:57183] PHP Fatal error: Unparenthesized `a ? b : c ? d : e` is not supported. Use either `(a ? b : c) ? ...https://www.isharkfly.com/t/php-unparenthesized-a-b-c-d-e-is-not-supported-use-eithe/15665

相关推荐
paterWang1 小时前
基于 Python 和 OpenCV 的酒店客房入侵检测系统设计与实现
开发语言·python·opencv
东方佑1 小时前
使用Python和OpenCV实现图像像素压缩与解压
开发语言·python·opencv
我真不会起名字啊2 小时前
“深入浅出”系列之杂谈篇:(3)Qt5和Qt6该学哪个?
开发语言·qt
laimaxgg2 小时前
Qt常用控件之单选按钮QRadioButton
开发语言·c++·qt·ui·qt5
水瓶丫头站住2 小时前
Qt的QStackedWidget样式设置
开发语言·qt
小钊(求职中)3 小时前
Java开发实习面试笔试题(含答案)
java·开发语言·spring boot·spring·面试·tomcat·maven
慕诗客5 小时前
QT基于Gstreamer采集的简单示例
开发语言·qt
Blasit5 小时前
C++ Qt建立一个HTTP服务器
服务器·开发语言·c++·qt·http
Victoria.a5 小时前
数组和指针常见笔试题(深度剖析)
c语言·开发语言
..过云雨5 小时前
04.类和对象(下)(初始化列表、static静态成员、友元friend[类外函数使用类私有成员]、内部类、匿名对象等)
开发语言·c++