PHP tmpfile() 函数

定义和用法
tmpfile() 函数以读写(w+)模式建立一个具有唯一文件名的临时文件。
文件会在关闭后(用 fclose())自动被删除,或当脚本结束后。
语法
tmpfile()
提示和注释
提示:参见 tempnam()。
例子
<?php
$temp = tmpfile();
fwrite($temp, "Testing, testing.");
//倒回文件的开头
rewind($temp);
//从文件中读取 1k
echo fread($temp,1024);
//删除文件
fclose($temp);
?>
$temp = tmpfile();
fwrite($temp, "Testing, testing.");
//倒回文件的开头
rewind($temp);
//从文件中读取 1k
echo fread($temp,1024);
//删除文件
fclose($temp);
?>
输出:
Testing, testing.
