note 41251 deleted from language.operators.comparison by crell
| From: | crell@php.net | Date: | Wed, 30 Mar 2022 21:46:50 +0000 |
| Subject: | note 41251 deleted from language.operators.comparison by crell | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-217788@lists.php.net to get a copy of this message | ||
Note Submitter: user@example
----
With Nested ternary Operators you have to set the logical parentheses to get the correct result.
<?php
$test=true;
$test2=true;
($test) ? "TEST1 true" : ($test2) ? "TEST2 true" : "false";
?>
This will output: TEST2 true;
correct:
<?php
$test=true;
$test2=true;
($test) ? "TEST1 true" : (($test2) ? "TEST2 true" : "false");
?>
Anyway don't nest them to much....!!