KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have seen advice that says the ternary operator must not be nested. I have tested the code below and it works okay. My question is, I haven't seen the ternary operator used like this before. So, is this as reliable as it were used in an if or could something like this come and bite me later(not in terms or readability, but by failing). $rule1 = true; $rule2 = false; $rule3 = true; $res = (($rule1 == true) && ($rule2 == false) && ($rule3 == true)) ? true : false; if($res) { echo "good"; } else { echo "fail"; } Thanks!
Tags (comma-separated)
Save Edits
Cancel