タスク: 最初のウォークスルー後にファイルをカットまたは消去します。
別のphpファイルを作成する「index.php」というインストールファイルがあります。
<?
/* here some code*/
$fh = fopen($myFile, 'w') or die("can't open file");
$stringData = "<?php \n
echo 'hallo, *very very long text*'; \n
?>";
fwrite($fh, $stringData);
/*herecut"/
/*here some code */
新しいファイルの作成後、このファイルが呼び出され、非常に長く、最初のインストールでのみ必要になるため、filecreation 呼び出しを消去するつもりです。
そのため、上記のコードに追加します
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);]}
現在のファイルを変更したり、最初の呼び出し後にファイルを「自己破壊」するための簡単な方法や関数はありませんか?
よろしく
編集:編集する方法を見つけました、zafに申し訳ありません
unlink(__FILE__);
実行後に「ヘルパーファイル」を削除するために使用できます。