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.
完整的PHP Filesystem參考手冊