note 41251 added to language.operators.comparison
| From: | user at example dot php dot net | Date: | Sun, 04 Apr 2004 07:17:24 +0000 |
| Subject: | note 41251 added to language.operators.comparison | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-67609@lists.php.net to get a copy of this message | ||
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....!!
----
Manual Page -- http://www.php.net/manual/en/language.operators.comparison.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+41251
Delete -- http://master.php.net/manage/user-notes.php?action=delete+41251&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+41251&report=yes
Search -- http://master.php.net/manage/user-notes.php