Tools, FAQ, Tutorials:
Removing a File in PHP
How To Remove a File in PHP?
✍: FYIcenter.com
If you want to remove an existing file, you can use the unlink() function. Here is a PHP script example on how to use unlink():
<?php
if (file_exists("/temp/todo.txt")) {
unlink("/temp/todo.txt");
print("File removed.\n");
} else {
print("File does not exist.\n");
}
?>
This script will print:
File removed.
If you run this script again, it will print:
File does not exist.
⇐ Removing an Empty Directory in PHP
2016-11-20, ∼2519🔥, 0💬
Popular Posts:
Where to find tutorials on EPUB file format? I want to know how to create EPUB books. Here is a larg...
How to convert a JSON text string to an XML document with PHP language? Currently, there is no built...
How To Loop through an Array without Using "foreach" in PHP? PHP offers the following functions to a...
How To Loop through an Array without Using "foreach" in PHP? PHP offers the following functions to a...
How To Copy Array Values to a List of Variables in PHP? If you want copy all values of an array to a...