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

Unlimited Access

Get Unlimited Contributor Access to the all ExamTopics Exams!
Take advantage of PDF Files for 1000+ Exams along with community discussions and pass IT Certification Exams Easily.

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
2 years, 6 months 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
3 years, 6 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]
3 years, 9 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 ...