Re: shorthand "if" notation
| From: | Shawn McKenzie | Date: | Wed, 11 Jun 2003 19:43:04 +0000 |
| Subject: | Re: shorthand "if" notation | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-151126@lists.php.net to get a copy of this message | ||
Ternary operator. Look in the comparison operators section:
http://us2.php.net/manual/en/language.operators.comparison.php
-Shawn
"Adrian Greeman" <adriangreeman@pixandwords.freeserve.co.uk> wrote in
message news:007901c33025$050458c0$162087d9@oemcomputer...
>
> I am confused by the shorthand "if" notation.
> For example I just saw this PHP snippet on another forum
>
> <?
> $bkgndClass = $bkgndClass == "darkBkgnd" ? "liteBkgnd" :
> "darkBkgnd";
> }
> ?>
>
> I think it is an if but cannot find it in the manual. How
> is that written in the more normal notation - if(){} etc??
>
> [And please excuse a slightly off-thread but related extension to
> the question but I have seen similar in Javascript - namely ---
> var evt = (evt ? evt : ((window.event) ? window.event : null);
> is this the same notation or something else?]
>
> Regards Adrian Greeman
>