PHP if , else , else if Statements


php PHP if , else , else if Statements Else If Statement

PHP if-else Statement

The if-else statement is used to make a decision , the decision depends upon the condition of if-else statement. Using if-else we can execute the different operations for different cases.

Daily Life Example:

Ali can only to the playground if Aslam comes to his home, otherwise he will play the video game at his home. ☄ What happed ? Aslam came to to Ali's house. ⇨ Condition checked. ⇨ They went to the playground.

PHP program for if-else statement

If number is greater then 10 display " Congratulations ! " other wise display " Did not Qualified ! " .

<?php $number = 11; if($number>10) { echo " Congratulations ! "; } else { echo " Did not Qualified ! "; } ?> Output: Congratulations !

PHP program for if-else and else if statements

If the number is equal to 10 display "You are near to Qualify ! " .If number is greater then 10 display " Congratulations ! " other wise display " Did not Qualified ! " . ⛱ Remember : There is only one if statement , one else statement and one or more else if statements in a single block.

<?php $number = 10; if($number==0) { echo " O ! You are at Zero "; } else if($number==10) { echo " You are near to Qualify ! "; } else if($number>10) { echo " Congratulations ! "; } else { echo " Did not Qualified ! "; } ?Output: You are near to Qualify !
php Else If Statement Chapter Next »