Php: PHP files: common methods for operating files: flie_put_contents (url, str); file_get_contents (url); file_put_contents ($ path, $ str); echofile_get_contents ($ path ); echo; file_put_conten
Common methods for file operations
Flie_put_contents (url, str );
File_get_contents (url );
When the file size is too large, you cannot use the above method to perform one-time operations on the above content. use the following function to solve the problem:
-
Fopen () open the file handle (the data stream channel between php and files)
Parameter 1: file address
Parameter 2: How to open the file. you can restrict the operation to be completed after opening the file.
File mode:
R (read) read mode
W (write) replaces the write mode and clears the file content. if the file does not exist, it is created.
A (append)
X replaces the write mode, clears the file content, and does not exist.
+ Expansion
R + read/write mode: place the file pointer in the file header
W + read/write mode, clear the file, put the file pointer in the file header
X + read/write mode: clears the file, places the file pointer in the file header, and does not automatically create the file
In a + read append write mode, write operations are always at the end, and read operations are limited by file pointers.
When both read and write operations can be performed, the difference is the file initialization.
-
Continuous read:
Fread (file handle [, length]); read the content of the specified length (bytes)
Fgets (file handle [, length]); reads the content of the specified length (bytes)
Length: refers to the read length-1 byte
The end of the row is the function termination operation.
Fgetc (file handle) reads one byte at a time
-
Fwrite (file handle, content );
Fclose (file handle );
Ftell (); find the pointer position
Fseek (); position of the pointer
R + read/write is affected by the pointer, and the original pointer content is replaced by the write
W + clear content
A | a + pointer has uncertainties. Read is affected by the pointer and write is appended.
Last modification time of filemtime (url) file
Filesize () file size
'). AddClass ('pre-numbering '). hide (); $ (this ). addClass ('Has-numbering '). parent (). append ($ numbering); for (I = 1; I <= lines; I ++) {$ numbering. append ($ ('
'). Text (I) ;}; $ numbering. fadeIn (1700) ;}) ;}; script
The above introduces the PHP file, including the php content, and hopes to help those who are interested in the PHP Tutorial.