Common ways to manipulate files
Flie_put_contents (URL,STR);
file_get_contents (URL);
$str = time();$path = './time.txt';echo'';file_put_contents($path,$str);echo file_get_contents($path);echo'';file_put_contents($path,"\r".$str,FILE_APPEND);echo file_get_contents($path);
When the file is too large, you can not use the above method to operate the above content, using the following function to solve
fopen () Open file handle (data flow channel between PHP and file)
Parameter 1: File address
Parameter 2: Open mode, which action you want to complete after opening a file, can be restricted at the pattern location
File mode:
R (read) read mode
W (write) replaces write mode, zeroing the contents of the file, creating
A (Append)
X replaces write mode, zeroing the contents of the file, does not exist without creating
+ Extended
r+ read-write mode, place the file pointer over the file header
w+ read-write mode, zeroing the file, placing the file pointer in the file header
x+ read-write mode, zeroing files, placing file pointers on file headers, not creating files automatically
A + read append write mode, the write operation is always at the end, the read operation is limited by the file pointer
When both can read and write operations, the different is the initialization of the file
Continuous reads:
Fread (file handle [, length]); Reads the contents of a specified length (bytes)
Fgets (file handle [, length]); Reads the contents of a specified length (bytes)
Length: Refers to the read length-1 bytes
At the end of the line is the function's terminating operation
FGETC (file handle) reads one byte at a time
Fwrite (file handle, content);
- Fclose (file handle);
- Ftell (); Finding the pointer position
- Fseek (); Positioning pointer position
R+ reads and writes are affected by pointers, and writes replace the original pointer contents
w+ Empty Content
A | A + pointer has an indeterminate factor, reading is affected by a pointer, and writing is an append
- Filemtime (URL) file Last modified
- 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); }); });
The above is the introduction of PHP files, including the content of PHP, I hope that the PHP tutorial interested in a friend helpful.