nerdexam
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)
  • A
    14% (5)
  • B
    78% (29)
  • C
    3% (1)
  • D
    5% (2)

Community Discussion

No community discussion yet for this question.

Full 200-550 Practice