method to read with a while to some fgets line
$file _name= "1.txt";
The code is as follows |
Copy Code |
$FP =fopen ($file _name, ' R '); while (!feof ($FP)) { $buffer =fgets ($fp, 4096); echo $buffer. " <br> "; } Fclose ($FP); |
Method two uses file to save to an array at once and then output with foreach
The code is as follows |
Copy Code |
$array = file ($file); foreach ($array as $v =>$_v) { echo $_v, ' <br/> '; } |
Method three uses file_get_contents once to read out
The code is as follows |
Copy Code |
if (Is_file ($file _name)) { $CN = file_get_contents ($file _name); Echo $CN; } |
/*
Correlation Function Reference Address
fopen http://www.111cn.net/phper/18/d5da4dcc30303f7684a91dec184e24fc.htm
Whether the feof to the end of the file
Fgets http://www.111cn.net/phper/21/php-fgets.htm
Fclose off
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
*/