Zend
200-710 · Question #11
What is the output of the following code? $a = 3; switch ($a) { case 1: echo 'one'; break; case 2: echo 'two'; break; default: echo 'four'; break; case 3: echo 'three'; break; }
The correct answer is C. three. See the full explanation below for the reasoning.
PHP Basics
Question
What is the output of the following code?
$a = 3;
switch ($a) {
case 1: echo 'one'; break;
case 2: echo 'two'; break;
default: echo 'four'; break;
case 3: echo 'three'; break;
}
Options
- Aone
- Btwo
- Cthree
- Dfour
How the community answered
(45 responses)- A4% (2)
- B9% (4)
- C71% (32)
- D16% (7)
Topics
#switch statement#default case#case ordering#control flow
Community Discussion
No community discussion yet for this question.