πŸ“Š PHP
Q. What will be the output?
Code:
function foo() {
  static $x = 0;
  $x++;
  return $x;
}
echo foo() . foo();
  • (A) 11
  • (B) 12
  • (C) 22
  • (D) Error
πŸ’¬ Discuss
βœ… Correct Answer: (B) 12

Explanation: Static variable retains value across calls.

Explanation by: Roshan
Static variable retains value across calls.

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
1
Total Visits
πŸ“½οΈ
8 d ago
Published
πŸŽ–οΈ
Roshan
Publisher
πŸ“ˆ
95%
Success Rate