Posted by juglesh on 09/16/05 21:03
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.
[Back to original message]
|