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

目录
相关文章
|
4月前
|
数据库连接
(node:2612) DeprecationWarning: collection.ensureIndex is deprecated. Use createIndexes instead.
(node:2612) DeprecationWarning: collection.ensureIndex is deprecated. Use createIndexes instead.
|
4月前
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.
|
5月前
|
Java
jpa中PageRequest @Deprecated和Sort @Deprecated的最新使用方法
jpa中PageRequest @Deprecated和Sort @Deprecated的最新使用方法
|
8月前
|
开发工具
WARNING: library configuration mismatch
WARNING: library configuration mismatch
185 0
|
Java 应用服务中间件 Android开发
Description Resource Path LocationType Java compiler level does not match the version of the instal
Description Resource Path LocationType Java compiler level does not match the version of the instal
172 0
Description Resource Path LocationType Java compiler level does not match the version of the instal
|
API Python
全网首发:warning: #warning “Using deprecated NumPy API, disable it by “ “#defining NPY_NO_DEPRECATED_API
全网首发:warning: #warning “Using deprecated NumPy API, disable it by “ “#defining NPY_NO_DEPRECATED_API
194 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
|
API
'getWidth()' is deprecated,'getHeight()' is deprecated
'getWidth()' is deprecated,'getHeight()' is deprecated
111 0
'getWidth()' is deprecated,'getHeight()' is deprecated
mTabLayout.setOnTabSelectedListener is deprecated
mTabLayout.setOnTabSelectedListener is deprecated
108 0
mTabLayout.setOnTabSelectedListener is deprecated
|
JSON 数据格式
sonar代码质量检测告警“static“ base class members should not be accessed via derived types
sonar代码质量检测告警“static“ base class members should not be accessed via derived types
715 0
sonar代码质量检测告警“static“ base class members should not be accessed via derived types