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: }