PHP 教程 PHP tmpfile() 函数

perry · 2022-03-07 12:47:00 · 热度: 12

定义和用法

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.

查看更多 PHP Filesystem 函数

猜你喜欢:
暂无回复。
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册