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, ∼2213🔥, 0💬
Popular Posts:
Can You Add Values to an Array without Keys in PHP? Can You Add Values to an Array with a Key? The a...
How to use the "set-variable" Policy Statement to create custom variables for an Azure API service o...
Can You Add Values to an Array without Keys in PHP? Can You Add Values to an Array with a Key? The a...
How To Read Data from Keyboard (Standard Input) in PHP? If you want to read data from the standard i...
How to add images to my EPUB books Images can be added into book content using the XHTML "img" eleme...