PHP: elseif statement

This entry is part 26 of 54 in the series PHP Tutorial

A partner of if else is the elseif statement.

As its name suggests, elseif is a combination of if and else.

<?php
$a = 10;
$b = 20;
$c = 30;
$d = 40;
if ($a == $b) {
    echo 'A is equal to B';
} elseif ($a == $c) {
    echo 'A is equal to C';
} elseif ($a == $d) {
    echo 'A is equal to D';
} else {
    echo 'A is actually not equal to anything';
}
?>
Series Navigation<< PHP: If else
PHP: While loop >>