<?php
function gen() {
echo 'start';
yield 'middle';
echo 'end';
}
// Initial call does not output anything
$gen = gen();
// Call to current() resumes the generator, thus "start" is echo'd.
// Then the yield expression is hit and the string "middle" is returned
// as the result of current() and then echo'd.
echo $gen->current();
// Execution of the generator is resumed again, thus echoing "end"
$gen->next();