Posted by chris on 09/17/05 11:35
thanks everyone for the explanations - all is clear now
there are so many different ways to do the same thing in PHP
Chris
"juglesh" <jugleshjunk@hotmail.com> wrote in message
news:1126893818.007680.120670@g43g2000cwa.googlegroups.com...
> http://www.php.net/manual/en/language.operators.comparison.php
> Ternary Operator
> Another conditional operator is the "?:" (or ternary) operator. Example
> 15-3. Assigning a default value
>
> <?php
> // Example usage for: Ternary Operator
> $action = (empty($_POST['action'])) ? 'default' : $_POST['action'];
>
> // The above is identical to this if/else statement
> if (empty($_POST['action'])) {
> $action = 'default';
> } else {
> $action = $_POST['action'];
> }
>
> ?>
>
> The expression (expr1) ? (expr2) : (expr3) evaluates to expr2 if expr1
> evaluates to TRUE, and expr3 if expr1 evaluates to FALSE.
>
> hard one to find if you dont know what yer lookin for.
>
Navigation:
[Reply to this message]
|