The elseif Statementif (expr) statement0 elseif statement1 . . . elseif statementN-1 else statementN The elseif statement works much like if and else together. Like else, it extends an if statement to execute a different statement in case the original if expression evaluates to FALSE. But unlike else, elseif will execute that alternative expression only if the elseif conditional expression evaluates to TRUE. For example, this displays various messages depending on whether $value1 is larger than $value2, equal to $value2, or less than $value2: <?php if ($value1 > $value2) { echo "$value1 is larger than $value2"; } elseif ($$value1 == $value2) { echo "$value1 is equal to $value2"; } else { echo "$value1 is less than $value2"; } ?> You can use several elseifs in the same if statement. Note that in PHP, you can also write "else if" (two words). |