LMSouq
php-dev Open

What does yield mean in PHP?

GO
Gordon
1 month ago
3 views
Problem Description
I've recently stumbled over this code: function xrange($min, $max) { for ($i = $min; $i <= $max; $i++) { yield $i; } } I've never seen this `yield` keyword before. Trying to run the code I get > Parse error: syntax error, unexpected T_VARIABLE on line x So what is this `yield` keyword? Is it even valid PHP? And if it is, how do I use it?

AI-Generated Solution

Powered by LMSouq AI · GPT-4.1-mini

✓ Solution Ready
Analyzing problem and generating solution…
Was this solution helpful?
Back to Knowledge Base