PHP 中的 tmpfile() 函数

phpprogrammingserver side programming更新于 2025/9/25 11:07:17

tmpfile() 函数创建一个唯一的临时文件。它返回新文件的文件指针,失败时返回 FALSE。

语法

tmpfile()

参数

  • 不适用

返回值

tmpfile() 函数返回新文件的文件指针,失败时返回 FALSE。

示例

<?php
   $tmpfile = tmpfile();
   fwrite($tmpfile, "This is demo text in temp file!");
   rewind($tmpfile);
   echo fread($tmpfile, 1024);
   fclose($tmpfile);
?>

输出

This is demo text in temp file!

相关文章