$file = new SplFileObject('/path/to/file.txt');
如何在SplFileObject中找到文件中的行数?
SplFileObject
如果你绝对必须使用spl,你可以这样做
$file = new SplFileObject("/path/to/file.txt"); $i = 0; while (!$file->eof()) { $i++; $file->next(); } print "file has " . $i . " lines";