ternary else if php code example
Example 1: if else if ternary php
var name = (variable === 1) ? 'foo' : ((variable === 2) ? 'bar' : 'baz');
Example 2: ternary expressions php
$result = $condition ? 'foo' : 'bar';
var name = (variable === 1) ? 'foo' : ((variable === 2) ? 'bar' : 'baz');
$result = $condition ? 'foo' : 'bar';