How to delete files regularly in php?

coldplay.xixi
Release: 2023-03-02 08:50:02
Original
2973 people have browsed it

How to delete files regularly in php: first create a new [flag.txt] file and enter 1 or 0 in it; then [1] means to continue execution, the code is [$flag = 1;]; finally the client When the client is disconnected, the script can continue to execute in the background, the code is [ignore_user_abort();].

How to delete files regularly in php?

How to regularly delete files in php:

The following code is a simple php that regularly cleans files in a folder code.

ps: This code will continue to be executed if the website is not restarted, so it is only used for local environment testing. Please do not test on the website.

The code is as follows:

Copy after login

Based on an idea found on the Internet, create a flag.txt file and enter 1 or 0 in it. "0" means to stop execution, and "1" means to continue. implement. This way it can be started and stopped.

The code is as follows:

Copy after login

php deletes the folder and all files under the folder

The code is as follows:

Copy after login

Example:Delete all ".svn" folders under a certain folder (including their contents must also be deleted).

The code is as follows:

Copy after login

Related learning recommendations: PHP programming from entry to proficiency

The above is the detailed content of How to delete files regularly in php?. 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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!