php - 我需要自己清理 tempnam() 创建的文件吗?

标签 php temporary-files

我创建了一堆 tempnam() 文件以供在我的请求期间使用。当不再需要它们时,我是否需要专门 unlink() 它们,或者 PHP/系统会自行处理它?<​​/p>

最佳答案

tempnam() 创建的文件不会被 PHP 删除。

你必须unlink()手动进行。


如果您需要 PHP 自动删除的临时文件,请考虑使用 tmpfile() :

Creates a temporary file

The file is automatically removed when closed (for example, by calling fclose(), or when there are no remaining references to the file handle returned by tmpfile()), or when the script ends.

关于php - 我需要自己清理 tempnam() 创建的文件吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72057808/

相关文章:

php - Symfony2 Twig 渲染函数中的内部路由

C++ tmpnam 替代方案

linux - 在管道中使用时更改 gunzip 临时目录

java - 删除 IntelliJ 的系统目录是否安全?

php - 从两个表中选择第二个表的 LIMIT 1

php - 如何编写和显示特定产品的评论?

php - 使用唯一/主键插入数据库

python-3.x - 当没有写入权限时,Python tempfile.TemporaryFile 在 Windows 上挂起

r - 在 R 中使用 tempfile() 创建的临时文件会发生什么?

javascript - 如何使用 PHP GET 请求打开 Bootstrap 模式?