php tutorial - PHP if elseif else Condition - php programming - learn php - php code - php script
- The if....elseif...else statement executes different codes for more than two conditions.
- The if...elseif...else is a special statement that is used to combine multiple if...else statements.
Learn PHP - PHP tutorial - If Elseif Statement - PHP examples - PHP programs
php programming Syntax :
learn php Sample Code : sample php program
php for beginners Code Explanation :
- In this code $t = date("Y"); specifies a variable $t that defines year.
- Here is the “if-elseif-else” statement where, the If condition executes the statements based on the true and false condition. Similarly, if the condition is false it executes the other elseif & if statements.
php coding Sample Output :
- Echo statements prints “You are in 2015” statement based on the execution of “IF Condition” which executes the condition to be true.
- Echo statements prints “You are in 2016” statement based on the execution of “elseif Condition” which executes the condition. (where the if condition is false).
- Echo statements prints “Wait for 2017” statement based on the execution of “else Condition” which executes the condition. (where the elseif condition is false).