PHP file deletion implementation _ PHP Tutorial

Source: Internet
Author: User
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...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.