php - Multiple conditions in the ternary operator safe? -


I have seen the advice that says that the ternary operator should not be nested.

I have tested the code below and it works fine. My question is, I have not seen the use of a ternary operator like this before, so it is reliable because it was used in a if or something like this and then bites me (no Due to context or readability, but also due to failure).

  $ rule1 = true; $ Rule2 = False; $ Rule3 = true; $ Res = (($ rule1 == true) & amp; ($ rule2 == incorrect) & amp; ($ rule3 == true))? right wrong; If ($ res) {echo "good"; } And {resonate "unsuccessful"; }   

Thanks!

If the results are returning from you, the Ternary operator is only "true" and "false", then you No operator required. You may just:

  $ res = (($ rule1 === true) & amp; ($ rule2 === incorrect) & amp; ($ rule3 === True))   

But to answer your question, yes many situations work perfectly well.

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -