Question:Which language construct can best represent the following series of if conditionals?<?php
if($a == 'a') {
somefunction();
} else if ($a == 'b') {
anotherfunction();
} else if ($a == 'c') {
dosomething();
} else {
donothing();
}
?>
A A switch statement without a default case
B A recursive function call
C A while statement
D It is the only representation of this logic
E A switch statement using a default case
+ ExplanationA series of if…else if code blocks checking for a single condition as above is a perfect place to use a switch statement:
Because there is a catch-all else condition, a default case must also be provided for that situation. Answer E is correct.