您的位置:首页 > 大数据

大数据文件和小数据文件读取

2016-02-17 15:54 495 查看
小数据文件: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);
}
?>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: