The elseif Statement

The elseif Statement:
There are also times when you want a number of different possibilities to occur, based upon a sequence of conditions. You can achieve this using else if statement. As you might imagine, it is like an else statement, except that you place a further conditional expression prior to the conditional code.

The Elseif
The Elseif
Exaample for elseif:

      <?php
         $d = date("D");
         
         if ($d == "Fri")
            echo "Have a nice weekend!";
         
         elseif ($d == "Sun")
            echo "Have a nice Sunday!"; 
         
         else
            echo "Have a nice day!"; 
      ?>

OUTPUT:
Have a nice Weekend!
Example for elseif:

<?php  
$num=12;  
if($num%2==0){  
echo "$num is even number";  
}else{  
echo "$num is odd number";  
}  
?>  

Output:
12 is even number 
Translate »