Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP file that should run once and delete itself. Is it possible?

Is it possible to create a PHP file that runs once with no errors and deletes itself?

like image 524
Rella Avatar asked Apr 05 '10 14:04

Rella


People also ask

Can I delete a PHP file?

To delete a file in PHP, use the unlink function. Let's go through an example to see how it works. The first argument of the unlink function is a filename which you want to delete. The unlink function returns either TRUE or FALSE , depending on whether the delete operation was successful.

Which PHP function is used to delete a file?

The unlink() function deletes a file.

Does PHP file need to end with ?>?

It's entirely optional but including it provides the opportunity to slip whitespace into the output by accident. If you do that in a file that you include or require before you try to output headers then you'll break your code.


1 Answers

<?php unlink(__FILE__); ?> 
like image 99
Matěj G. Avatar answered Sep 27 '22 19:09

Matěj G.