PHP unlink()Functions
Complete PHP Filesystem Reference Manual
Definition and Usage
The unlink() function deletes a file.
If successful, the function returns TRUE. If it fails, it returns FALSE.
Syntax
unlink(filename,context)
| Parameters | 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 can modify the behavior of streams. |
Example
<?php
$file = "test.txt";
if (!unlink($file))
{
echo ("Error deleting $file");
}
else
{
echo ("Deleted $file");
}
?>
$file = "test.txt";
if (!unlink($file))
{
echo ("Error deleting $file");
}
else
{
echo ("Deleted $file");
}
?>
Complete PHP Filesystem Reference Manual Other Extensions