PHP Ternary Operator are binary operators which combine two operands or expressions into a single but more complex expression. PHP has some unary and one ternary operators as well. Unary operators convert a single expression into a more complex expression and a ternary operator combines three expressions into a single expression.
Ternary Operator in PHP is faster and cleaner way through which we can write simple if/else statements.
Syntax:
Portion to the left of the ? is a condition of testing. Portion between the ? and the : is the result/output if the condition is true. Portion after the : is the result/output if the condition is false.
This will produce following result: