if condition ternary operator php code example
Example 1: php ternary operator
(Condition) ? (Statement1) : (Statement2);
Example 2: if else if ternary php
var name = (variable === 1) ? 'foo' : ((variable === 2) ? 'bar' : 'baz');
(Condition) ? (Statement1) : (Statement2);
var name = (variable === 1) ? 'foo' : ((variable === 2) ? 'bar' : 'baz');