Changes in PHP ternary operator since PHP 5.3

Till PHP 5.2

$varName = ($cond) ? $cond : ‘false’;

From PHP 5.3

$varName = ($cond) ? : ‘false’;

No need to write condition for true. It will automatically taken $cond in true.

 
Changes in PHP Ternary Operator since PHP 5.3
(Visited 36 times, 2 visits today)