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:

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

Have a nice Weekend!
Example for elseif:

echo "$num is even number";  
echo "$num is odd number";  

12 is even number 
Translate »