Thursday, July 25, 2013

Ternary conditional operator in PHP?

Ternary conditional operator:
Expression preceding the ? is evaluated, if it’s true, then the expression preceding  the : is executed, otherwise, the expression following : is executed.


Syntax:
Condition ? value if true :value if false;


Example:

$id = isset($_POST['name']) ?  $_POST['name'] : false;
?>