Can php delete files?

藏色散人
Release: 2023-03-14 18:16:01
Original
2496 people have browsed it

php can delete files. The method of deleting files: 1. Create a PHP sample file; 2. Find the file to be deleted; 3. Delete the file through the "unlink(filename,context)" syntax. .

Can php delete files?

#The operating environment of this article: Windows 7 system, PHP version 7.1, Dell G3 computer.

Can php delete files?

php can delete files.

php can use the unlink function to delete files

The specific usage is as follows

unlink($filename);
Copy after login

unlink() Function introduction:

unlink() Function deletes files.

If successful, this function returns TRUE. On failure, returns FALSE.

Syntax

unlink(filename,context)
Copy after login

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 can modify the behavior of the stream.

Example

<?php
$file = "test.txt";
if (!unlink($file))
{
echo ("Error deleting $file");
}
else
{
echo ("Deleted $file");
}
?>
Copy after login

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of Can php delete files?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
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