Combinations of If-Else Constructs in PHP
Let the variable $num be able to take
values 1, 2, or 3.
Let's also assume that for each value we want
to output different strings. To solve
this problem, you can simply write three if
statements without the else construct:
<?php
$num = 1; // can be 1, 2, or 3
if ($num === 1) {
echo 'variant 1'; // will work if $num is 1
}
if ($num === 2) {
echo 'variant 2'; // will work if $num is 2
}
if ($num === 3) {
echo 'variant 3'; // will work if $num is 3
}
?>
The variable $day contains some number
from the interval 1 to 31. Determine
which decade of the month this number falls into.