php ternaire short code example Example 1: php ternary $result = $condition ? 'foo' : 'bar'; Example 2: php ternary shorthand $y = $x ? "true" : "false";