Create Delete File

	/* Create new file */
	$filename = "myFile.txt";
	/* Open file in write mode */
	$file = fopen($filename, "w") or die("Unable to open file!");
	$txt = "My first file!";
	/* Write text into file */
	fwrite($file, $txt);
	/* Close file */
	echo "File created successfully!<br />";
	/* Delete file */
	/* Checking is file exist or not */
	if(is_file($filename)) {
		/* Unlink(delete) file */
			echo "File deleted successfully!";
			echo "File can't be delete...try again!";
		echo "File no found!";

/* Output */
File created successfully!

File deleted successfully!

Comments (0)

  • To add your comment please or

We use cookies to improve your experience on our site and to show you personalised advertising. Please read our cookie policy and privacy policy.

Got It!