Home  >  Article  >  Backend Development  >  How to delete files regularly in php?

How to delete files regularly in php?

coldplay.xixi
coldplay.xixiOriginal
2020-07-10 09:35:182968browse

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:

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:

php deletes the folder and all files under the folder

The code is as follows:

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

The code is as follows:

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!

Statement:
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