PHP unlink() Function
Definition and Usage
The unlink() function deletes a file.
If successful, returns true, otherwise returns false.
Syntax
unlink(filename,context)
Parameter | Description |
---|---|
filename | Required. Specifies the file to be deleted. |
context | Optional. Specifies the environment for the file handle. Context is a set of options that modify the behavior of a stream. |
Tips and Comments
Note:for context Support was added in PHP 5.0.0.
Example
<?php $file = "test.txt"; if (!unlink($file)) { echo ("Error deleting $file"); } else { echo ("Deleted $file"); } ?>