note 95997 added to language.operators.comparison
| From: | crazy888s at hotmail dot com | Date: | Tue, 02 Feb 2010 06:32:05 +0000 |
| Subject: | note 95997 added to language.operators.comparison | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-165587@lists.php.net to get a copy of this message | ||
I couldn't find much info on stacking the new ternary operator, so I ran some tests:
<?php
echo 0 ?: 1 ?: 2 ?: 3; //1
echo 1 ?: 0 ?: 3 ?: 2; //1
echo 2 ?: 1 ?: 0 ?: 3; //2
echo 3 ?: 2 ?: 1 ?: 0; //3
echo 0 ?: 1 ?: 2 ?: 3; //1
echo 0 ?: 0 ?: 2 ?: 3; //2
echo 0 ?: 0 ?: 0 ?: 3; //3
?>
It works just as expected, returning the first non-false value within a group of expressions.
----
Server IP: 69.147.83.197
Probable Submitter: 98.220.56.129
----
Manual Page -- http://www.php.net/manual/en/language.operators.comparison.php
Edit -- https://master.php.net/note/edit/95997
Del: integrated -- https://master.php.net/note/delete/95997/integrated
Del: useless -- https://master.php.net/note/delete/95997/useless
Del: bad code -- https://master.php.net/note/delete/95997/bad+code
Del: spam -- https://master.php.net/note/delete/95997/spam
Del: non-english -- https://master.php.net/note/delete/95997/non-english
Del: in docs -- https://master.php.net/note/delete/95997/in+docs
Del: other reasons-- https://master.php.net/note/delete/95997
Reject -- https://master.php.net/note/reject/95997
Search -- https://master.php.net/manage/user-notes.php