SplFileObject read file

$file = new SplFileObject("file.txt");
while (!$file->eof()) {
    echo $file->fgets();
}
function lines($filename) {
    $file = new SplFileObject($filename);
    while (!$file->eof()) {
        yield $file->fgets();
    }
}

foreach (lines('German.txt') as $line) {
    echo $line;
}
15 июня 2020, 20:37