PHP file deletion method_PHP tutorial

WBOY
Release: 2016-07-13 17:44:15
Original
793 people have browsed it

The unlink() function deletes files.
Returns true if successful, false if failed.
Syntax
unlink(filename,context)
Parameter 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.

$file_delete = "home/meeta/my.php";

if (unlink($file_delete)) {
echo "The file was deleted successfully. ", "n";
} else {
echo "The specified file could not be deleted. Please try again.", "n";
}
?>The judgment file is added below Does it exist

$myfile = "./test1.txt";
if (file_exists($myfile)) {
$result=unlink ($myfile);
echo $ result;
}
?>
file_exists() function checks whether the file or directory exists.
Returns true if the specified file or directory exists, false otherwise.
Syntax
file_exists(path)


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/478761.htmlTechArticleunlink() function deletes files. Returns true if successful, false if failed. Syntax unlink(filename,context) Parameter Description filename Required. Specifies the files to be deleted. con...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!