According to me the Switch Case is easy to understand. In a switch, a condition is evaluated only once, and the result is compared to each box. In an elseif statement, the conditions are evaluated in each comparison. If your condition is more complicated than a simple comparison, or is part of a loop switch is faster. A special case is the default. This case is used when all other cases have failed. For example :
PHP Code:
<?php
switch ($i) {
case 0:
echo "i equals 0";
break;
case 1:
echo "i equals 1";
break;
case 2:
echo "i equals 2";
break;
default:
echo "i is not equal to 0, 1 or 2";
}
?>
Bookmarks