What does yield mean in PHP?
Answers (2)
Add AnswerThe yield keyword is at the heart of a generator function. In its most basic form, a yield statement resembles a return statement, except that instead of halting the function and returning, yield gives the code looping over the generator a value and pauses the generator function’s execution.
To make a generator function, use the yield keyword. Generator functions are iterators that can be looped through using the foreach loop.
The yield keyword returns a value that is used as a value in one of the loop’s iterations.