Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
355 views
in Technique[技术] by (71.8m points)

PHP Deprecated: Unparenthesized

I found this debug error: PHP Deprecated: Unparenthesized a ? b : c ? d : e is deprecated. Use either (a ? b : c) ? d : e or a ? b : (c ? d : e) in /home/ptl4lmmge5kb/public_html/wp-content/plugins/give-recurring/includes/admin/class-subscriptions-list-table.php on line 143

The code from line 143 of the plugin shows this:

  ( ( 'all' === $key && empty( $current ) ) ) ? 'class="current"' : ( $current == $key ) ? 'class="current"' : '',

Can anyone tell me where to place the parenthesis?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Taking their first request they are asking you to use a format like this (a ? b : c) ? d : e in this

 ( ( 'all' === $key && empty( $current ) ) ) ? 'class="current"' : ( $current == $key ) ? 'class="current"' : ''

breaking it down into their terminaology in this case:

a is ( 'all' === $key && empty( $current ) ) - there was an unneeded pair of brackets here, I've removed them as we've got enough problems sorting out brackets as it is

b is 'class="current"'

c is ( $current == $key )

d is 'class="current"'

e is ''

what they are saying is that they want you to make it plain what is going to be tested for the second ? by putting the condition and result of the first in parentheses

The first is: (a ? b : c)

which becomes ( ( 'all' === $key && empty( $current ) ) ? 'class="current"' : ( $current == $key ) )

So they ask that you use:

( ( 'all' === $key && empty( $current ) ) ? 'class="current"' : ( $current == $key ) ) ? 'class="current"' : ''

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...