Because of the next contact with the use of PHP crawler, and crawled data sometimes in order to save database resources, need to save as a local text file, so here to organize a PHP related file operation functions. First, open the file
First Open File fopen
Resource fopen (String $filename, String $mode)
FileName: File path to be opened
Mode: Modes to open files
Writes are rewritten if you want to append a to the end of the file.
Second, read the file
Read one row fgets () in the file
Fgets (Resource $handle, [, int $length])
Handle is an open file handle with a default length of 1KB, which is 1024 bytes. Stops when a line break, EOF, or a specified length is reached.
Read character FGETSC
Fgetc (Resource $handle)
The handle file pointer must be valid and must point to a file that was successfully opened by fopen () or Fsockopen (), which returns a string containing a character that is obtained from the file that handle points to, and returns false when it encounters EOF.
Third, obtain the file attributeLast access Time Fileatime ()
int Fileatime (string $filename)
Gets the last access time, returns false on failure, returns the Unix timestamp (the time () function in format 1970-01-01t00:00:00z,php) file modified Filemtime ()
int Filemtime (string $filename)
Returns the time the file was last modified when successful, false when it fails, and time can return file size in Unix timestamp filesize ()
int FileSize (string $filename)
Returns the number of bytes in the file size on success, returns false on failure, and generates a e_waring-level error file type filetype ()
String filetype (string $filename)
Possible return values are Fifo,char,dir,block,link,file,unknown file synthesis Information stat ()
Array stat (string $filename)
Returns information about the last access, modification time, and size of the file.