Short Hand If
Short Hand If
To write shorter code, you can write if statements on one line.
One-line if statement:
Example:
$a = 5;
if ($a < 10) $b = "Hello";
echo $b
Output:
Short Hand If...Else
if...else statements can also be written in one line, but the syntax is a bit different.
Example
One-line if...else statement:
example:
$a = 13;
$b = $a < 10 ? "Hello" : "Good Bye";
echo $b;
Output: