PHP tmpfile() 函數

定義和用法
tmpfile() 函數以讀寫(w+)模式創建一個具有唯一檔案名的臨時檔。
語法
tmpfile()
提示和注釋
注釋:臨時檔會在檔關閉後(用 fclose())或當腳本結束後自動被刪除。
提示:參見 tempnam()。
實例
<?php
$temp = tmpfile();
fwrite($temp, "Testing, testing.");
//Rewind to the start of file
rewind($temp);
//Read 1k from file
echo fread($temp,1024);
//This removes the file
fclose($temp);
?>
$temp = tmpfile();
fwrite($temp, "Testing, testing.");
//Rewind to the start of file
rewind($temp);
//Read 1k from file
echo fread($temp,1024);
//This removes the file
fclose($temp);
?>
上面的代碼將輸出:
Testing, testing.
