1<?php
2#Syntex
3(if Condition) ? (stat1) : (stat2);
4
5#example
6$var1 = 5;
7$var2 = 2;
8
9echo $check = ($var1 > $var2) ? "right" : "wrong";
10
11#output : right
12/*
13explination : if condition is true then display the stat1 and if condition is
14worng then display stat2
15*/
16?>
1// Both ternary and if/else returns the same result
2
3// ternary
4$result = $condition ? 'foo' : 'bar';
5
6// if/else
7if ($condition) {
8 $result = 'foo'
9} else {
10 $result = 'bar'
11}