Ternary Operators
This operator takes three arguments – a condition, a result for true, and a result for false.
It is a shortcut of doing if statements. Here’s an example:
$result = ($a < 16) ? 'true' : 'false';
if ($a < 16) {
$result = 'true';
} else {
$result = 'false';
}
It is a shortcut of doing if statements. Here’s an example:
$result = ($a < 16) ? 'true' : 'false';
if ($a < 16) {
$result = 'true';
} else {
$result = 'false';
}
Comments