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, ∼2227🔥, 0💬
Popular Posts:
How to use the "send-one-way-request" Policy statement to call an extra web service for an Azure API...
How to create a new API on the Publisher Dashboard of an Azure API Management Service? If you are ne...
How to use the built-in "context" object in Policy expressions? The built-in "context" object can be...
Tools, FAQ, Tutorials: JSON Validator JSON-XML Converter XML-JSON Converter JSON FAQ/Tutorials Pytho...
How To Access a Global Variable inside a Function? in PHP? By default, global variables are not acce...