Home > Article > Backend Development > 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__); ?>
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();
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!