我创建了一堆 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 bytmpfile()
), or when the script ends.
关于php - 我需要自己清理 tempnam() 创建的文件吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72057808/