Nested If Statements in PHP
if else constructs can be nested
within each other arbitrarily. See the
example:
<?php
$num = 3;
if ($num >= 0) {
if ($num <= 5) {
echo 'less than or equal to 5';
} else {
echo 'more than 5';
}
} else {
echo 'less than zero';
}
?>
Let the variable $age store a number.
If this number is less than 10 or greater than
99, then display a message
about it. If the number falls within the specified
range, then find the sum of the digits of this number.
If the resulting sum is less than or equal to 9,
then display a message that
the sum of digits is single-digit, otherwise
display a message that the sum of digits
is two-digit.