Programming Languages PHP Objective
Sep 23, 2025

What is the correct way to implement a PHP generator function?

Choose the correct answer:
A) Use return statement
B) Use yield statement
C) Use generate statement
D) Use iterator statement
Detailed Explanation

Explanation: Generator functions use the yield keyword instead of return. Generators provide memory-efficient iteration by generating values on-demand rather than creating arrays in memory.

Discussion (0)

No comments yet. Be the first to share your thoughts!

Share Your Thoughts
Feedback