PHP – File Delete – Unlink Function

by Hiroshi on June 23, 2008

in File, File Manipulation

When you view the contents of a directory you can see all the files that exist in that directory because the operating system or application that you are using displays a list of filenames. You can think of these filenames as links that join the files to the directory you are currently viewing. If you unlink a file, you are effectively causing the system to forget about it or delete it! Before you can delete (unlink) a file, you must first be sure that it is not open in your program. Use the fclose function to close down an open file.

PHP – Unlink Function

<?php
$myFile = "testFile.txt";
unlink($myFile);
?>

In this case file named as testFile.txt will be deleted which is in the same directory as unlink script file is.

Related Posts

Previous post:

Next post: