07 Feb 2014
PHP – Create folder and a file in the folder
I worked on a project in that project we have to create folders and then files in that folders. is_dir is a function that checks whether a directory exists or not. mkdir creates a driectory, file_put_contents is a function that create file and places contents in that file.
Following the example code.
if(!is_dir("files")) mkdir("files"); $file_name = "files/first.html"; $text = "This is my first file"; file_put_contents($file_name, $text);