Ec(2); use whileto read file_name"=1.txt & quot; & nbsp; the Code is as follows: copy the code $ fpfopen ($ file_name, r); & nbsp; while (! Feof ($ fp) & nbsp ;{& nbsp; $ bufferfgets ($ fp, 4096); & nbsp; e script ec (2); script
// Method 1 use while to read some fgets rows
$ File_name = "1.txt ";
| The Code is as follows: |
|
$ Fp = fopen ($ file_name, 'R '); While (! Feof ($ fp )) { $ Buffer = fgets ($ fp, 4096 ); Echo $ buffer ." "; } Fclose ($ fp ); |
// Method 2: Save the file to the array once and use foreach to output
| The Code is as follows: |
|
$ Array = file ($ file ); Foreach ($ array as $ v =>$ _ v) { Echo $ _ v ,' '; } |
// Method 3: Read data at a time using file_get_contents
| The Code is as follows: |
|
If (is_file ($ file_name )) { $ Cn = file_get_contents ($ file_name ); Echo $ cn; } |
/*
Related function reference address
Fopen http://www.111cn.net/phper/18/d5da4dcc30303f7684a91dec184e24fc.htm
Whether feof is to the end of the file
Http://www.111cn.net/phper/21/php-fgets.htm fgets
Close fclose
File http://www.111cn.net/phper/24/f5d9e092cfa826b89c45b339bdd3dd4f.htm
File_get_contents http://www.111cn.net/phper/24/f8d52eaae81ea27383375ead36ffbd4d.htm
Foreach http://www.111cn.net/phper/18/foreach-foreach.htm
*/