Which language construct can best represent the following series of if conditionals?
if($a == 'a') { somefunction(); } else if ($a == 'b') { anotherfunction(); } else if ($a == 'c') { dosomething(); } else { donothing(); }
A switch statement without a default case
A recursive function call
A switch statement using a default case
A while statement
A series of if…else if code blocks checking for a single condition as above is a perfect place to use a switch statement