elseif- it’s nothing but, else iftherefore, practically no elseif, it’s just convenience. The same convenience is not provided for the ternary operator, since the ternary operator is designed for very short logic.
if ($a) { ... } elseif ($b) { ... } else { ... }
coincides with
if ($a) { ... } else { if ($b) { ... } else { ... } }
Therefore, the triple equivalent
$a ? ( ... ) : ( $b ? ( ... ) : ( ... ) )
source
share