Home > Backend Development > PHP Tutorial > A PHP file that should be run once and automatically delete itself. Is this possible?

A PHP file that should be run once and automatically delete itself. Is this possible?

WBOY
Release: 2023-08-29 06:00:01
forward
764 people have browsed it

A PHP file that should be run once and automatically delete itself. Is this possible?

Yes, it can be done using the unlink function. As shown below -

<?php unlink(__FILE__); ?>
Copy after login

Another alternative way to delete the script, whether or not the exit function is called, as shown below ^minus;

class DeleteOnExit {
   function __destruct() {
      unlink(__FILE__);
   }
}
$delete_on_exit = new DeleteOnExit();
Copy after login

The above is the detailed content of A PHP file that should be run once and automatically delete itself. Is this possible?. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
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