// 獲取文件行數 function getFileLineCount($fileName) { $fp = fopen($fileName, "r"); $line = 0; while (!feof($fp)) { //每次讀取1M if ($data = fread($fp, 1024 * 1024 * 1)) { //計算讀取到的行數 $num = substr_count($data, "\n"); $line += $num; } } fclose($fp); return $line; }