How to delete (unlink) a file.
TAGS: unlink, PHP, delete, file


In PHP deleting a file is called to 'unlink' a file.
The code is very simple. Here is an example of how to delete the file.txt that we made earlier. Notice that you will not get any warnings. If you need such, then you will have to make that yourself.

<?php
unlink('file.txt');
?>


If your file is not at the path of the PHP script, then remember to write the path to the file.