Task: cut or delete the file after the first pass.
I have an installation file called "index.php" that creates another php file.
<? $fh = fopen($myFile, 'w') or die("can't open file"); $stringData = "<?php \n echo 'hallo, *very very long text*'; \n ?>"; fwrite($fh, $stringData);
after creating a new file, this file is called, and I intend to erase the filecreation, since it is very long and is needed only during the first installation.
i to add to the above code
echo 'hallo, *very very long text*'; \n ***$new= file_get_contents('index.php'); \n $findme = 'habanot'; $pos = strpos($new, $findme); if ($pos === false) { $marker='herecut';\n $new=strstr($new,$marker);\n $new='<?php \n /*habanot*/\n'.$new;\n $fh = fopen('index.php', 'w') or die 'cant open file'); $stringData = $new; fwrite($fh, $stringData); fclose($fh);*** ?>"; fwrite($fh, $stringData);]}
Is there an easier way or function to change the current file or even βdestroyβ the file after the first call?
Hi
EDIT: found a way to edit, sorry zaf
unlink(__FILE__);
can be used to delete the "auxiliary file" after execution.
Email source share