First, write the file:
$fp = fopen (FileName, mode);
Mode for open file mode such as ' A + ' means to read and write files, file does not exist to create, new data main added to the end of the file
fwrite ($fp, write content );
Fclose ($FP);
Second, lock the file: when there are multiple users at the same time on the file operation to ensure that there is no conflict
Fclock ($FP, lock type); Lock types include write-exclusive, read-share ...
Third, read the file:
$data = file (' filename path ');
Places the data that is read into the array of data, with each element being a line of the file.
Coding test: ws.php:
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "Http://www.w3.org/TR/html4/loose.dtd" >
Test drawing:Starting:
Results:
V. Handling file uploads:
The 1.form tag must contain: Enctype= "Multipart/form-data", the form must be using the Post method
2. A hidden input box must be added and the maximum upload file size (in bytes) of the browser is recommended.
3. Create form fields <input type= "file" name= "Thefile"/>
Code test: ws.php:
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "Http://www.w3.org/TR/html4/loose.dtd" >
VI. Catalogue1. Navigation directory:
Find all contents in directory: Scandir ();
eg: $stuff = scandir (' directory name ');//function returns an array containing the files and directories in the directory, copied to $stuff
2. Create a directory:
mkdir (' path name ');
PHP Basic Tutorial--4 File and Directory Learning summary