Re: note 9441 added to Operator Precedence
| From: | Lars Torben Wilson | Date: | Fri, 03 Nov 2000 02:28:26 +0000 |
| Subject: | Re: note 9441 added to Operator Precedence | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-7316@lists.php.net to get a copy of this message | ||
carl@wurb.com writes:
> 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";
>
> http://www.php.net/manual/language.operators.precedence.php
Thanks for the note, but this is indeed documented on the Comparison
Operators page (but you're right: it should probably be in the table
there).
http://www.php.net/manual/language.operators.comparison.php
Cheers,
Torben
--
+----------------------------------------------------------------+
|Torben Wilson <torben@php.net> Netmill iTech|
|http://www.coastnet.com/~torben http://www.netmill.fi|
|Ph: 1 250 383-9735 torben@netmill.fi|
+----------------------------------------------------------------+