A switch statement consists of “cases”…
But is there any “else” case for all other cases?
Have never found the answer to this…
ex:
switch ($var){
case "x":
do stuff;
break;
case "y":
do stuff;
break;
else: // THIS IS WHAT I WOULD LIKE
do stuff;
break;
}
Typically the
defaultclause should be at the very end of your othercaseclauses for general readability.You may also want to reformat your
breakstatements in your code to look like this:Extra information on the
switchstatement available here and here.