Deal of The Day! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

Zend 200-710 Exam - Topic 4 Question 103 Discussion

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;}
C) three
A) one
B) two
D) four

Zend 200-710 Exam - Topic 4 Question 103 Discussion

Actual exam question for Zend's 200-710 exam
Question #: 103
Topic #: 4
[All 200-710 Questions]

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;

}

Show Suggested Answer Hide Answer
Suggested Answer: C

Contribute your Thoughts:

0/2000 characters
Colton
4 days ago
I thought it would be 'one' at first.
upvoted 0 times
...
Gregg
10 days ago
Wait, why is 'four' in the default?
upvoted 0 times
...
Tamekia
15 days ago
Totally agree, it's case 3!
upvoted 0 times
...
Gracie
20 days ago
The output is 'three'.
upvoted 0 times
...
Latia
25 days ago
Wait, I’m confused about the order of cases. Does the switch stop after the first match, or does it check all cases?
upvoted 0 times
...
Salena
1 month ago
I practiced a similar question where the switch statement had a default case too, and it seems like 'three' should be the output here.
upvoted 0 times
...
Dierdre
1 month ago
I'm not entirely sure, but I remember something about the default case being executed if no matches are found.
upvoted 0 times
...
Sharee
1 month ago
I think the switch statement will match the value of $a, which is 3, so it should output 'three'.
upvoted 0 times
...
Ines
2 months ago
Wait, does the default case get executed if there's a match? I feel like I might be mixing that up with something else.
upvoted 0 times
...
Adell
3 months ago
I practiced a similar question last week, and I think the order of cases matters. Since $a is 3, it should definitely go to case 3.
upvoted 0 times
...
Gearldine
3 months ago
I'm not entirely sure, but I remember something about the default case being executed if no matches are found.
upvoted 0 times
...
Ettie
3 months ago
I think the switch statement checks the value of $a, so it should match case 3 and output 'three', right?
upvoted 0 times
...

Save Cancel