note 9441 deleted from Operator Precedence by torben
| From: | torben@php.net | Date: | Fri, 03 Nov 2000 02:28:49 +0000 |
| Subject: | note 9441 deleted from Operator Precedence by torben | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-7315@lists.php.net to get a copy of this message | ||
The ternary functional conditional operator (?:) is listed in the precedence chart, but doesn't
seem to be defined anywhere in the operator documentation. It's familiar from C and related
languages, but since some people are learning PHP as their first language, it is well to define it
here.
foo ? bar : baz
will return bar if foo is true, and baz if foo is false. In other words, it's like an
"if..else" statement inside an expression. For example:
echo "Your number is ", ($x>4)? "too big" : "just right";