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