Zend
200-710 · Question #87
How many times will the function counter() be executed in the following code? function counter ($start, &$stop) { if ($stop > $start) { return; } counter ($start--, ++$stop); } $start = 5; $stop =…
The correct answer is C. 5. See the full explanation below for the reasoning.
Functions
Question
How many times will the function counter() be executed in the following code?
function counter ($start, &$stop)
{
if ($stop > $start)
{
return;
}
counter ($start--, ++$stop);
}
$start = 5;
$stop = 2;
counter ($start, $stop);
Options
- A3
- B4
- C5
- D6
How the community answered
(46 responses)- A2% (1)
- B11% (5)
- C83% (38)
- D4% (2)
Topics
#recursion#pass by reference#execution count#post-decrement
Community Discussion
No community discussion yet for this question.