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
~                                                                                                                                                                                                                                                                                                             

2024-04-25_13-22-44

错误原因

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) ? …icon-default.png?t=N7T8https://www.isharkfly.com/t/php-unparenthesized-a-b-c-d-e-is-not-supported-use-eithe/15665

  • 24
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

HoneyMoose

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值