The Elseif Statement
For example:
<?php
$age = 21;
if ($age<=13) {
echo "Child.";
} elseif ($age>13 && $age<19) {
echo "Teenager";
} else {
echo "Adult";
}
//Outputs "Adult"
?>
$age = 21;
if ($age<=13) {
echo "Child.";
} elseif ($age>13 && $age<19) {
echo "Teenager";
} else {
echo "Adult";
}
//Outputs "Adult"
?>
We used the logical AND (&&) operator to combine the two conditions and check to determine whether $age is between 13 and 19.
No comments:
Post a Comment