Stealth Generator

A function becomes a generator as soon as the yield keyword is added to the block of code. At that point, the function may be called, but it won’t do anything until the yield are executed. The code continues its execution, though.

<?php

function foo() {
    print a;
    yield 2;
    print b;
}

foo();
print c;

?>

Documentation

See also Stealth generator in action.

Related : Generator, Yield, yield from Keyword, Coroutine, Async, Lazy Loading