if, elseif, else are used to run different code blocks depending on a condition — for example, checking whether a user is logged in, whether stock is available, whether someone's old enough, or whether a form is valid.
php
<?php
$score = 82;
if ($score >= 90) {
echo "Grade A";
} elseif ($score >= 80) {
echo "Grade B";
} elseif ($score >= 60) {
echo "Grade C";
} else {
echo "Try again. Practice is the real cheat code.";
}
?>You should see
Grade B