PHP Ternary operator

Ternary operator conditional operators are used for executing code if a given statement is true or false. Ternary conditional operators are used to reduce space used by if-else statements.

Ternary Operator(?:)

If the condition is true, then the first statement. Else the second statement is the output.

(Conditional Statement) ? (Return value1) : (Return value2);

  $m = 10;
  echo ($m < 0) ? 'The number is negative' : 'The number is positive';



The number is positive