# Conditionals
# Ternary operators
// concise
$isMain = ($item->type === 'main');
// verbose
$isMain = $item->type == 'main' ? true : false;
# Ternary operators ( multiple nested conditions)
$result = ($num == 0)
? "Zero" : (($num > 0)
? (($num % 2 == 0)
? "Positive Even" : "Positive Odd")
: (($num % 2 == 0) ? "Negative Even" : "Negative Odd"));
$result = ($item == 'abc')
? "Zero"
: (($num > 0)
? (($num % 2 == 0)
? "Positive Even" : "Positive Odd")
: (($num % 2 == 0) ? "Negative Even" : "Negative Odd"));