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.
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.
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 !
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 !