Php file creation code: & lt ;? Php $ datadate (Ymd); $ dir/hom/kyle/file/$ data; $ filename/home/kyle/file/$ data/testfile; $ filecontent: this is the content to be written. test the space. // You can check whether a folder exists. otherwise, create if (! Is_dir ($ dir explains the code for creating a file instance in php:
- $ Data = date ("Ymd ");
- $ Dir = "/hom/kyle/file/$ data ";
- $ Filename = "/home/kyle/file/$ data/testfile ";
- $ Filecontent = "this is the content to be written test space ";
- // Determine whether the folder exists; otherwise, create
- If (! Is_dir ($ dir )){
- Mkdir ($ dir, 0777 );
- }
- // Determine whether the file exists; otherwise, create
- If (! File_exists ($ filename) {$ handle = fopen ($ filename, w );
- If (! $ Handle ){
- Echo create file fail;
- Exit;
- } Else {
- Chmod ($ filename, 0777 );
- }
- If (fwrite ($ handle, $ filecontent) === FALSE ){
- Echo "cant write into $ filename ";
- Exit;
- }
- Fclose ($ handle );
- }
- ?>