Unparenthesized `a ? b : c ? d : e` is deprecated. Use either `(a ? b : c) ? d : e` or `a ? b : (c ?

简介: Unparenthesized `a ? b : c ? d : e` is deprecated. Use either `(a ? b : c) ? d : e` or `a ? b : (c ?

自己的小程序api升级到PHP7.4结果报错了。看下原来的代码:

$remark = $chargeType == 2 ? 'VIP题库' : $type == 4 ? '历史题库' : '章节题库';

是不是看起来很恶心难于理解,不错是我写的,为了快速上线盈利嘛。在买来的小程序中的js代码还有10层以上的套娃写法,差点改恶心死我了。

php7.4告诉我的代码太垃圾不好理解,让我加上括号,于是代码变成下面这样。

$remark = ($chargeType == 2 ? 'VIP题库' : $type == 4) ? '历史题库' : '章节题库';

加上括号是不是清晰了?哈哈,还是烂代码,不过解决问题了。这样对于php解释器来读取也方便,对于我们阅读也方便。php果真是世界上最好的语言。

目录
相关文章
|
7月前
|
Python
【Error】DeprecationWarning: executable_path has been deprecated, please pass in a Service object
【Error】DeprecationWarning: executable_path has been deprecated, please pass in a Service object
124 2
error ‘.native‘ modifier on ‘v-on‘ directive is deprecated
error ‘.native‘ modifier on ‘v-on‘ directive is deprecated
DeprecationWarning:current URL string parser is deprecated, and will be removed in a future version.
DeprecationWarning:current URL string parser is deprecated, and will be removed in a future version.
jpa中PageRequest @Deprecated和Sort @Deprecated的最新使用方法
jpa中PageRequest @Deprecated和Sort @Deprecated的最新使用方法
【问题记录】utureWarning: Function get_feature_names is deprecated; get_feature_names is deprecated in 1.0
【问题记录】utureWarning: Function get_feature_names is deprecated; get_feature_names is deprecated in 1.0
|
API
'getWidth()' is deprecated,'getHeight()' is deprecated
'getWidth()' is deprecated,'getHeight()' is deprecated
153 0
'getWidth()' is deprecated,'getHeight()' is deprecated
mTabLayout.setOnTabSelectedListener is deprecated
mTabLayout.setOnTabSelectedListener is deprecated
147 0
mTabLayout.setOnTabSelectedListener is deprecated
|
API
'getColor(int)' is deprecated ,getColor过时
'getColor(int)' is deprecated ,getColor过时
275 0
'getColor(int)' is deprecated ,getColor过时
|
Java
Drools7.0.0.Final Unsupported major.minor version 52.0异常
Drools7.0.0.Final Unsupported major.minor version 52.0异常
142 0