php8 ternary if 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';