The unlink() function is a built-in function in PHP, used to delete files. The syntax is [unlink(filename,context)]. It takes the file name of the file that must be deleted as a parameter. It returns True when successful and returns when failed. False.
How to use the php unlink() function?
Function: Delete files.
Syntax:
unlink(filename,context)
Parameters:
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.
Return value: If successful, return true, if failed, return false.
php unlink() function example
<?php $file = "./test.txt"; if (!unlink($file)) { echo ($file."删除失败"); } else { echo ($file."删除成功"); } ?>
This article is an introduction to the PHP unlink function. I hope it will be helpful to friends in need!
The above is the detailed content of How to use php unlink function. For more information, please follow other related articles on the PHP Chinese website!