one line php ternary operator code example
Example 1: php inline if
/* most basic usage */
$var = 5;
$var_is_greater_than_two = ($var > 2 ? true : false); // returns true
Example 2: php ternary shorthand
$y = $x ? "true" : "false";
/* most basic usage */
$var = 5;
$var_is_greater_than_two = ($var > 2 ? true : false); // returns true
$y = $x ? "true" : "false";