Calling it runs nothing
A generator function that logs before its first yield. Watch when that log appears.
<?phpfunction count3() { echo 'start' . PHP_EOL; yield 1; yield 2;}$gen = count3();echo 'created' . PHP_EOL;foreach ($gen as $n) { echo "got $n" . PHP_EOL;}1. Predict the output
Tap the lines in the order you think they print.
- 1…
- 2…
- 3…
- 4…