1:  //方法一 用while来些fgets一行行读
   2:  $file_name="1.txt";
   3:  $fp=fopen($file_name,\'r\');
   4:    while(!feof($fp))
   5:    {
   6:     $buffer=fgets($fp,4096);
   7:     echo $buffer."<br>";
   8:    }
   9:    fclose($fp);
  10:   
  11:   
  12:   
  13:  // 方法二 用file一次保存到数组再用foreach输出
  14:   
  15:  $array = file( $file );
  16:  foreach( $array as $v =>$_v )
  17:  {
  18:     echo $_v,\'<br />\';
  19:  }
  20:   
  21:   
  22:  //方法三用file_get_contents一次读出
  23:   
  24:  if( is_file( $file_name ) )
  25:  {
  26:    $cn = file_get_contents( $file_name );
  27:    echo $cn;
  28:  }

.csharpcode, .csharpcode pre { font-size: small; color: rgba(0, 0, 0, 1); font-family: consolas, “Courier New”, courier, monospace; background-color: rgba(255, 255, 255, 1) }
.csharpcode pre { margin: 0 }
.csharpcode .rem { color: rgba(0, 128, 0, 1) }
.csharpcode .kwrd { color: rgba(0, 0, 255, 1) }
.csharpcode .str { color: rgba(0, 96, 128, 1) }
.csharpcode .op { color: rgba(0, 0, 192, 1) }
.csharpcode .preproc { color: rgba(204, 102, 51, 1) }
.csharpcode .asp { background-color: rgba(255, 255, 0, 1) }
.csharpcode .html { color: rgba(128, 0, 0, 1) }
.csharpcode .attr { color: rgba(255, 0, 0, 1) }
.csharpcode .alt { background-color: rgba(244, 244, 244, 1); width: 100%; margin: 0 }
.csharpcode .lnum { color: rgba(96, 96, 96, 1) }

版权声明:本文为ecstore原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/ecstore/archive/2013/07/13/3158137.html