PHP unlink() Function
❮ PHP Filesystem ReferenceExample
Delete a file:
<?php
$file = "test.txt";
if (!unlink($file)) {
echo ("Error deleting $file");
}
else {
echo ("Deleted $file");
}
?>
Definition and Usage
The unlink() function deletes a file.
Syntax
unlink(filename, context)
Parameter Values
| Parameter | Description |
|---|---|
| filename | Required. Specifies the path to the file to delete |
| context | Optional. Specifies the context of the file handle. Context is a set of options that can modify the behavior of a stream |
Technical Details
| Return Value: | TRUE on success, FALSE on failure |
|---|---|
| PHP Version: | 4.0+ |
| PHP Changelog: | PHP 5.0 - Added the context parameter |
❮ PHP Filesystem Reference

