Fopen is used to create files in php, and \ w \ or \ w + "is used to create files, the fopen function requires two important information blocks to run normally. First, we must provide the file. We want it to open it and name it. Second, we must tell us what functions we need to plan to create files with this file. fopen will be used to create files in php, it will be created using \ "w \" or \ "w +, the fopen function requires two important information blocks to run normally. First, we must provide the file. We want it to open it and name it. Second, we must tell us what features to plan with this file
Script ec (2); script
*/
The Code is as follows: |
|
$ Fn = 'www.111cn.net.txt' $ Fcon = 'php how to create a file'; // content If ($ f = fopen ($ fn, "w ")) { If (fwrite ($ f, $ fcon )) { Echo 'file written successfully '; } Else { Echo 'file not write '; } Fclose ($ f ); } Else { Echo 'The file cannot be created. Check the authorization '; } |
/*
$ Fn = 'www.111cn.net.txt '; create a file name
Open the "w" Write mode, point the file pointer to the file header, and cut the file size to zero. If the file does not exist, try to create it.
Open in "w +" read/write mode, point the file pointer to the file header, and cut the file size to zero. If the file does not exist, try to create it.
Fclose ($ r) // close the opened file. The file handle required for fclose is closed.
The original tutorial on this site is reproduced with the source www.111cn.net
*/