Thursday, April 1, 2010

what is ternary conditional operator?

example:

$result= (empty($_REQUEST['id'])) ? 'default' : 'exp3';

in this example $result is default if the $_REQUEST['id'] is true otherwise $result is exp3

If we saying simply means

The expression (expr1) ? (expr2) : (expr3) evaluates to expr2 if expr1 evaluates to TRUE, and expr3 if expr1 evaluates to FALSE.

No comments:

Post a Comment