Example
Test a second condition if the first condition is not met:
html
<?php
if(5 < 3) {
echo "Five is less than three";
} else
if(5 > 4) {
echo "Five is greater than four";
}
?>
Definition and Usage
The elseif keyword tests a new condition if the condition of a previous if or elseif statement was not met. It is equivalent to putting an if statement inside an else block.
The following blocks of code are equivalent:
html
<?php
if (...) {
some code here
} elseif (...) {
some
code here
}
?>
html
<?php
if (...) {
some code here
} else{
if (...)
{
some code here
}
}
?>
Related Pages
The if keyword.