How to create a file using php

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

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.