Home > Backend Development > PHP Tutorial > How to use php unlink function

How to use php unlink function

藏色散人
Release: 2023-04-05 10:58:01
Original
3768 people have browsed it

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 php unlink function

How to use the php unlink() function?

Function: Delete files.

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 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."删除成功");
}
?>
Copy after login

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!

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