tmpfile

(PHP 3 >= 3.0.13, PHP 4, PHP 5)

tmpfile -- 建立一個暫存檔案

說明

resource tmpfile ( void )

以讀寫(w+)模式建立一個具有唯一檔案名的暫存檔案,返回一個與 fopen() 所返回相似的檔案識別碼。檔案會在關閉後(用 fclose())自動被移除,或當腳本結束後。

詳細訊息請參考系統手冊中的 tmpfile(3) 函數,以及 stdio.h 標頭檔。

例子 1. tmpfile() 例子

<?php
$temp 
tmpfile();
fwrite($temp"writing to tempfile");
fseek($temp0);
echo 
fread($temp1024);
fclose($temp); // this removes the file
?>

上例將輸出:

writing to tempfile

參見 tempnam()