Home  >  Article  >  Backend Development  >  Let a PHP file delete itself after executing it once

Let a PHP file delete itself after executing it once

藏色散人
藏色散人Original
2020-08-19 10:06:102278browse

How PHP deletes itself: First create a PHP sample file; then use the "$file = "zzz.php"; if (file_exists($file)) {@unlink ($file);}" method Just delete it.

Let a PHP file delete itself after executing it once

Recommended: "PHP Video Tutorial"

Many friends need to make the file only accessible when using php Access once, (such as cms program installation, database query or modification) then how to let php delete itself, we can use the following code to complete:

$file = "zzz.php";  
if (file_exists($file)) {  
     @unlink ($file);  
}

Specify $file as zzz.php, then when When the program runs here, the file zzz.php will be deleted. Of course, you can also specify $file as the php code itself.

The above is the detailed content of Let a PHP file delete itself after executing it once. 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