title: PHP unlink OR rewrite own/current file by itself
body: <p>Task: Cut or erase a file after first walk-through.</p>
  
  <p>i have an install file called "index.php" which creates another php file.</p>
  
  <pre><code>&lt;? 
  /* here some code*/
  $fh = fopen($myFile, 'w') or die("can't open file");
  $stringData = "&lt;?php \n
  echo 'hallo, *very very long text*'; \n 
  ?&gt;";
  fwrite($fh, $stringData);
  /*herecut"/
  /*here some code */
  </code></pre>
  
  <p>after the creation of the new file this file is called and i intent to erase the 
  filecreation call since it is very long and only needed on first install.</p>
  
  <p>i therefor add to the above code</p>
  
  <pre><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='&lt;?php \n /*habanot*/\n'.$new;\n
  $fh = fopen('index.php', 'w') or die 'cant open file');
  $stringData = $new;
  fwrite($fh, $stringData);
  fclose($fh);***    
  
  ?&gt;";
  fwrite($fh, $stringData);]}
  </code></pre>
  
  <p>Isnt there an easier way or a function to modify the current file or even "self destroy" a file after first call?</p>
  
  <p>Regards</p>
  
  <p>EDIT: found the way to edit, sorry to zaf</p>
  
  <pre><code>unlink(__FILE__);
  </code></pre>
  
  <p>can be used to delete the "helper file" after execution.</p>