Conditional statements are used to perform different actions based on different conditions. They allow your PHP applications to make decisions!
if StatementThe if statement executes some code if one condition is true.
<?php $t = 14;if ($t < 20) { echo "Have a good day!"; } ?>
if...else StatementThe if...else statement executes some code if a condition is true and another code if that condition is false.
if...elseif...else StatementThe if...elseif...else statement executes different codes for more than two conditions.
<?php $t = 22;if ($t < 10) { echo "Have a good morning!"; } elseif ($t < 20) { echo "Have a good day!"; } else { echo "Have a good night!"; } ?>