In this post you will learn how to create a file using PHP. In PHP, a file is created using a command that is also used to open files.
In PHP the fopen function is used to open files. However, it can also create a file if it does not find the file specified in the function call. So if you use fopen on a file that does not exist, it will create it.
Find the php code below to create the file
$filename = "myfile.php"; // File Name here
$createfile = fopen($filename, 'w') or die("can't open file"); // Command to create the file if file is not available it will create it.
fclose($createfile); // It will close the file which was opened
Your file will be created in the same directory with this code if you want to change be created in another directory set the file path accordingly.