If not, it meant if, if it meant, that means “if not”. If a condition does not match with this statement, we can try another condition immediately after. For example, let’s make a score assessment with elseif
. If our grade is 5, then let’s print very good if it is 4, good if it is 3, middle and if it is 2 or 1 print failed.
<?php
$grade = 5;
if($grade === 5) {
echo 'Very good!';
} elseif($grade === 4) {
echo 'Good';
} elseif($grade === 3) {
echo 'Middle';
} elseif($grade === 2) {
echo 'Failed';
} elseif($grade === 1) {
echo 'Failed';
}
?>
This will print us Very Good
.