<?php
/**
* 按行读取文件
* @param string $filename
*/
function readFileByLine ($filename)
{
$fh = fopen($filename, 'r'); //打开一个文件
while (! feof($fh)) { //判断是否到文章末尾
$line = fgets($fh); //按行读取
echo $line;
}
fclose($fh);
}
// test
$filename = "/home/wzy/test/sort.txt";
readFileByLine($filename);