2011-10-04 49 views
0

我想知道是否可以用php腳本創建一個臨時頁面。基本上我想要做的是在example.com/example/button.php上有一個文件,它將訪問php腳本,並在example.com/example/temppage.php上創建文本。我只是需要它在關鍵詞上說「關機」30秒,然後它可以回到空白狀態。在Php中創建一個臨時文件

這是可能的嗎?謝謝!

+0

*(參考)* http://php.net/ spltempfileobject和http://php.net/tmpfile – Gordon

+0

http://blog.stackoverflow.com/2011/02/are-some-questions-too-simple/ – Gordon

+0

我想知道如果你的想法是一個臨時文件是基於upo如果您只是不熟悉php及其生成動態內容的能力,你需要在服務器上創建一個臨時文件嗎? – horatio

回答

1

嘗試tmpfile()

<?php 
$temp = tmpfile(); 
fwrite($temp, "writing to tempfile"); 
fseek($temp, 0); 
echo fread($temp, 1024); 
fclose($temp); // this removes the file 
?> 
1

有居然是:click!

或者,如果你懶得點擊:d

$temp = tmpfile(); 
fwrite($temp, "writing to tempfile"); 
fseek($temp, 0); 
echo fread($temp, 1024); 
fclose($temp); // this removes the file 
+0

這是朝正確的方向邁出的一步,但是我需要一個特定名稱的臨時文件,在30秒後刪除。可能嗎? – Konzine