PHP short-ternary (“Elvis”) operator vs null coalescing operator

When your first argument is null, they’re basically the same except that the null coalescing won’t output an E_NOTICE when you have an undefined variable. The PHP 7.0 migration docs has this to say: The null coalescing operator (??) has been added as syntactic sugar for the common case of needing to use a ternary … Read more

Ternary Operator

Well, the ternary operator in Java acts like this… return_value = (true-false condition) ? (if true expression) : (if false expression); …Another way of looking at it… return_value = (true-false condition) ? (if true expression) : (if false expression); You question is kind of vague and we have to assume here. If (and only if) … Read more