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);
?>
上のコードの出力は、次の通り:
Testing, testing.