PHP tmpfile() 函數(shù)
完整的 PHP Filesystem 參考手冊
定義和用法
tmpfile() 函數(shù)以讀寫(w+)模式創(chuàng)建一個具有唯一文件名的臨時文件。
語法
提示和注釋
注釋:臨時文件會在文件關閉后(用 fclose())或當腳本結(jié)束后自動被刪除。
提示:參見 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);
?>
上面的代碼將輸出:
完整的 PHP Filesystem 參考手冊