Ternary if() elseif() else

It’s very important where you place parenthesis in nested ternary operators. Basically if you want a nest a ternary operator in an existing ternary operator you need to put parentheses around the whole thing your nesting.

$a ? $b : ( $c ? $d : ( $e ? $f : $g ) )

The following should work “as planned” :


$var = $action == 'edit' ? 'Edit' : ($action == 'delete' ? 'Delete' : 'New');

:slight_smile: