#15. IF Else IF Statements
IF Else IF Statementsif (condition1)
{
//These statements would execute if the condition1 is true
}
else if(condition2)
{
//These statements would execute if the condition2 is true
}
.
.
else
{
//These statements would execute if all the conditions return false.
}Run Code:<?php$time = 22;
if ($time < 10) { echo "Good morning.";
} else if ($time < 20) {
echo "Good day.";
} else {
echo "Good evening.";
}
// Outputs "Good evening."?>
Comments
Post a Comment