PHP Create File

This PHP script will create a file if it doesn’t exist.


* Create a Text File
* This script creates a new file. 
* @author		PHP Simple
* @website
* @date			August 2021

$write_str = "Replace this text with what you want written in the file.\nThis sentence will go on a new line.";

// Opens the file or creates it if it doesn't exist
$txfile = fopen("filename.txt", "w") or die("Unable to open file!");

// Write content to the file
fwrite($txfile, $write_str);

// Close the file