小数据文件:file_get_contents
大数据:fgets
<?php
$file = "log.txt";
$handle = @fopen($file, "r");
$begin_arr = explode(" ", microtime());
echo "start: ".$begin_arr[1]."<br>";
if ($handle)
{
flock($handle, LOCK_EX);//只有file函数读写才能有效
$i = 1;
while (!feof($handle))
{
$buffer = fgets($handle);
$i++;
}
echo "<br>run: ".$i;
$end_arr = explode(" ", microtime());
echo "end: ".$end_arr[1]."<br>";
echo $end_arr[1] -$begin_arr[1];
flock($handle, LOCK_UN);
fclose($handle);
}
?>