这里使用的yield 方法
function readTheFile($path) {
$handle = fopen($path, 'r');
while(!feof($handle)) {
yield trim(fgets($handle));
}
fclose($handle);
}
$iterator = readTheFile('shakespeare.txt');
foreach ($iterator as $item) {
echo $item;
}