zoukankan      html  css  js  c++  java
  • 大数据文件和小数据文件读取

    小数据文件: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);
            }
    ?>

  • 相关阅读:
    重构与模式:改善代码三部曲中的第三部
    将博客搬至CSDN
    管理之道(二十二)
    管理之道(二十一)
    管理之道(二十)
    管理之道(十九)
    管理之道(十八)
    管理之道(十七)
    管理之道(十六)
    管理之道(十五)
  • 原文地址:https://www.cnblogs.com/legend-song/p/5195609.html
Copyright © 2011-2022 走看看