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果真是世界上最好的语言。

目录
相关文章
|
5月前
|
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
89 2
|
4月前
|
机器学习/深度学习 数据处理 Python
【Python】已解决:FutureWarning: Function get_feature_names is deprecated; get_feature_names is deprecated
【Python】已解决:FutureWarning: Function get_feature_names is deprecated; get_feature_names is deprecated
74 0
error ‘.native‘ modifier on ‘v-on‘ directive is deprecated
error ‘.native‘ modifier on ‘v-on‘ directive is deprecated
|
6月前
Classic mode for store/ is deprecated and will be removed in Nuxt 3
Classic mode for store/ is deprecated and will be removed in Nuxt 3
114 0
|
11月前
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.
|
11月前
|
数据库连接
(node:2612) DeprecationWarning: collection.ensureIndex is deprecated. Use createIndexes instead.
(node:2612) DeprecationWarning: collection.ensureIndex is deprecated. Use createIndexes instead.
jpa中PageRequest @Deprecated和Sort @Deprecated的最新使用方法
jpa中PageRequest @Deprecated和Sort @Deprecated的最新使用方法
|
开发工具
WARNING: library configuration mismatch
WARNING: library configuration mismatch
312 0
【问题记录】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
java中出现Syntax error, annotations are only available if source level is 1.5 or greater
java中出现Syntax error, annotations are only available if source level is 1.5 or greater
java中出现Syntax error, annotations are only available if source level is 1.5 or greater