PHP to read the file content code of TXT js etc

  • 2020-03-31 17:01:32
  • OfStack

< ? PHP

The function read_file_content ($FileName)
{
/ / open the file
$fp = fopen ($FileName, "r");
$data = "";
While (! The feof ($fp))
{
/ / read the file
$data. = fread ($fp, 4096);
}
/ / close the file
Fclose ($fp);
/ / delete the file
/ / unlink ($FileName);
//return the content from the file
Echo $data;
}
A.h read_file_content (" HTML ")
? >
The difference between fread and fgets
Fread: calculates the length in bytes, reads the data at the specified length and times, and stops when the end is reached or the specified length is read.
Fgets: reads a full line and stops at the end or line return. Used in text mode.

Related articles: