Zend
200-550 · Question #66
What is the output of the following code? function fibonacci (&$x1 = 0, &$x2 = 1) { $result = $x1 + $x2; $x1 = $x2; $x2 = $result; return $result; } for ($i = 0; $i < 10; $i++) { echo fibonacci()…
The correct answer is B. 1,1,1,1,1,1,1,1,1,1. See the full explanation below for the reasoning.
Question
What is the output of the following code? function fibonacci (&$x1 = 0, &$x2 = 1) { $result = $x1 + $x2; $x1 = $x2; $x2 = $result; return $result; } for ($i = 0; $i < 10; $i++) { echo fibonacci() . ','; }
Options
- AAn error
- B1,1,1,1,1,1,1,1,1,1,
- C1,1,2,3,5,8,13,21,34,55,
- DNothing
How the community answered
(37 responses)- A14% (5)
- B78% (29)
- C3% (1)
- D5% (2)
Community Discussion
No community discussion yet for this question.