views:

262

answers:

2

PHP file that should run once with no errors and delete itself. Is it possible? How to create such file?

A: 

On linux try:

<?php
system( 'rm filename.php' );

And then write back if there was a success.

smentek
Might be a better idea to use PHP's `unlink`, and use a value in the `$_SERVER` array in place of the hardcoded 'filename.php', to make it more portable?
LeguRi
Does `unlink` not work in a windows environment?
LeguRi
true unlink is better.
smentek
@smentek Hm.. I use XAMPP apache on windows... So I wonder for some crossplatform way...
Blender
+8  A: 
<?php unlink(__FILE__); ?>
Matěj Grabovský