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 6 Question 102 Discussion

What is the output of the following code?function ratio ($x1 = 10, $x2){if (isset ($x2)) {return $x2 / $x1;}}echo ratio (0);
D) A warning, because $x2 is not set
A) 0
B) An integer overflow error
C) A warning, because $x1 is not set
E) A floating-point overflow error
F) Nothing

Zend 200-710 Exam - Topic 6 Question 102 Discussion

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

What is the output of the following code?

function ratio ($x1 = 10, $x2)

{

if (isset ($x2)) {

return $x2 / $x1;

}

}

echo ratio (0);

Show Suggested Answer Hide Answer
Suggested Answer: D

Contribute your Thoughts:

0/2000 characters
Susana
4 days ago
I vote for D too. It’s clear $x2 is missing.
upvoted 0 times
...
Rebbecca
10 days ago
I feel like it’s a warning, but I’m not sure if it’s D or C.
upvoted 0 times
...
Darell
15 days ago
But isn’t D more accurate? It warns about $x2.
upvoted 0 times
...
Billy
20 days ago
I’m leaning towards A. It returns 0 since $x2 is 0.
upvoted 0 times
...
Gerald
25 days ago
Yeah, I agree with D. The function needs $x2.
upvoted 0 times
...
Jeffrey
1 month ago
I think it should be D. $x2 is not set.
upvoted 0 times
...
Justa
1 month ago
I disagree, it should just return nothing.
upvoted 0 times
...
Kristofer
1 month ago
Wait, why is $x1 even a factor here?
upvoted 0 times
...
Hoa
2 months ago
Definitely not an integer overflow error!
upvoted 0 times
...
Clay
3 months ago
I think it's a warning because $x2 isn't set.
upvoted 0 times
...
Tina
3 months ago
The output will be 0.
upvoted 0 times
...
Luke
4 months ago
I’m leaning towards option D, but I’m not completely confident since I can’t recall how PHP handles default values in this context.
upvoted 0 times
...
Marti
4 months ago
This reminds me of a practice question where a missing parameter caused a warning. I feel like that might happen here too.
upvoted 0 times
...
Shad
4 months ago
I remember something about default parameters, but I’m confused if $x2 being unset will cause a warning or not.
upvoted 0 times
...
Ula
4 months ago
I think the function will return 0 since $x2 is passed as 0, but I'm not entirely sure about the default value of $x1.
upvoted 0 times
...

Save Cancel