Home > Article > Backend Development > Definition and usage of PHP unlink() function
This article brings you the definition and usage of the PHP unlink() function. Friends in need can refer to the
unlink() function to delete files.
If successful, return true, otherwise return false.
unlink(filename,context)
Parameters | Description |
---|---|
filename | Required. Specifies the files to be deleted. |
context | Optional. Specifies the environment for a file handle. Context is a set of options that modify the behavior of the stream. |
Note: Support for context was added in PHP 5.0.0.
<?php $file = "test.txt"; if (!unlink($file)) { echo ("Error deleting $file"); } else { echo ("Deleted $file"); } ?>
Related recommendations:
The above is the detailed content of Definition and usage of PHP unlink() function. For more information, please follow other related articles on the PHP Chinese website!