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

相关推荐
狐凄5 分钟前
Python实例题:Python计算概率论
开发语言·python·概率论
q5673152329 分钟前
分布式增量爬虫实现方案
开发语言·分布式·爬虫·python
勤奋的知更鸟35 分钟前
LLaMA-Factory和python版本的兼容性问题解决
开发语言·python·llama-factory
CIb0la37 分钟前
Ai自动补全编程工具:llama vscode
运维·开发语言·学习·测试工具·程序人生
1candobetter1 小时前
JAVA后端开发——多租户
java·开发语言
freyazzr1 小时前
C++八股 | Day3 | 智能指针 / 内存管理 / 内存分区 / 内存对齐
开发语言·c++
序属秋秋秋1 小时前
《C++初阶之入门基础》【普通引用 + 常量引用 + 内联函数 + nullptr】
开发语言·c++·笔记
星辰离彬1 小时前
Java 高级泛型实战:8 个场景化编程技巧
java·开发语言·后端·程序人生
纨妙1 小时前
python打卡day47
开发语言·python
ghost1431 小时前
C#学习第29天:表达式树(Expression Trees)
开发语言·c#