IF statement is an important conditional and logical statement in PHP. If, else construct is used to add logic in php code.
If else construct syntax:
If (conditions) { // Execute these codes if condition is true } else { // Execute these codes if condition is false }
Example:
<?php $a = 50; if($a > 30) { echo "Congrats!! $a is greater than 30"; } else { echo "Sorry, $a is less than 30"; } ?>