PHP unlink()Functions


PHP Filesystem 参考手册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");
}
?>


PHP Filesystem 参考手册Complete PHP Filesystem Reference Manual Other Extensions