Welcome to ExamTopics
ExamTopics Logo
- Expert Verified, Online, Free.
exam questions

Exam 200-550 All Questions

View all questions & answers for the 200-550 exam

Exam 200-550 topic 1 question 85 discussion

Actual exam question from Zend's 200-550
Question #: 85
Topic #: 1
[All 200-550 Questions]

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);

  • A. 3
  • B. 4
  • C. 5
  • D. 6
Show Suggested Answer Hide Answer
Suggested Answer: C 🗳️

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
linkmaster
3 years, 1 month ago
Correct answer is 5? brcause: 1 run for start=5 and stop=2 2 run for start=5 and stop=3 3 run for start=5 and stop=4 4 run for start=5 and stop=5 and again... 5 run for start=5 and stop=6 will return without changes for $stop variable
upvoted 1 times
...
chayan_1089
4 years, 2 months ago
function counter($start, &$stop) { static $x = 0; $x++; if ($stop > $start) { echo $x; return; } counter($start--, ++$stop); } $start = 5; $stop = 2; counter($start, $stop);
upvoted 1 times
...
[Removed]
4 years, 5 months ago
I think the correct answer is B: 4 times. when running this code in PHP 7.x, i got 4 time notice : Notice: Only variables should be passed by reference in ... on line 9
upvoted 1 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...