Php file deletion implementation method. The unlink () function deletes a file. If the call succeeds, true is returned. if the call fails, false is returned. The parameter description of the syntax unlink (filename, context) is required. Specifies the file to be deleted. The con unlink () function deletes a file.
If the call succeeds, true is returned. if the call fails, false is returned.
Syntax
Unlink (filename, context)
Parameter description
Filename is required. Specifies the file to be deleted.
Context is optional. Specifies the file handle environment. Context is a set of options for modifying stream behavior.
$ File_delete = "home/meeta/my. php ";
If (unlink ($ file_delete )){
Echo "The file was deleted successfully.", "n ";
} Else {
Echo "The specified file cocould not be deleted. Please try again.", "n ";
}
?> The following code checks whether a file exists.
$ Myfile = "./test1.txt ";
If (file_exists ($ myfile )){
$ Result = unlink ($ myfile );
Echo $ result;
}
?>
The file_exists () function checks whether a file or directory exists.
If the specified file or directory exists, true is returned; otherwise, false is returned.
Syntax
File_exists (path)
The http://www.bkjia.com/PHPjc/478761.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/478761.htmlTechArticleunlink () function removes files. If the call succeeds, true is returned. if the call fails, false is returned. The parameter description of the syntax unlink (filename, context) is required. Specifies the file to be deleted. Con...