"One" File system overview
File creation, deletion, editing, copying, pasting (moving), i.e. file additions and deletions
"Two" read the file
Open read: ReadFile (String), passing in the file path to open the read (if read succeeds, the number of bytes returned)
Open assignment to Variable: file_get_contents (), return character type
Open Read Close step: fopen,fread,fclose
①fopen has two parameters, fopen (open path, open mode), open as read/write only
②fread has two parameters, fread (read file name, optional, read maximum byte limit)
③fclose close files to prevent open files from occupying server resources
fopen Open File Mode list:
R Read-only , pointing the file pointer to the file header;
r+ Reading and writing , pointing the file pointer to the file header;
W writes Open , points the file pointer to the file header and intercepts the file size to 0. Create a file if the file does not exist
w+ Read-write mode opens , pointing the file pointer to the file header and intercepting the file size to 0. Create a file if the file does not exist
A write mode opens , pointing the file pointer to the end of the file. Create a file if the file does not exist
A + read-write mode opens , pointing the file pointer to the end of the file. Create a file if the file does not exist
X is created and opened in write mode . If it already exists, the fopen () call fails to return false and generates an error message with a e_warning warning level. If the file does not exist, try to create
X+ is created and opened as read-write . ...
"Three" Create modified file contents
(1) Get the contents of the file
File_get_contents return string
$contents = file_get_contents ('./new.txt'"$contents ";
(2) write the contents of the file
file_put_contents return byte length
Writes a string to the specified file, creates a file if it does not exist, and returns the length of bytes written
$contents = file_put_contents ('./new1.txt',' I'm new content ' "$contents";
(3)
(Lone solitary Nine swords)--php Video Learning--File system