(PHP 7)
Generator::getReturn — Get the return value of a generator
This function has no parameters.
Returns the generator's return value once it has finished executing.
Example #1 Generator::getReturn() example
<?php
$gen = (function() {
yield 1;
yield 2;
return 3;
})();
foreach ($gen as $val) {
echo $val, PHP_EOL;
}
echo $gen->getReturn(), PHP_EOL;
The above example will output:
1 2 3