Memory mapped files in PHP, what is the difference between php://temp and php://memory

梦想的初衷 提交于 2019-12-23 16:27:47

问题


I am in need of a way to store a file in memory very briefly in PHP, the file is being built and then sent right off to another web service. I see that as of PHP 5.1 the php://temp and php://memory streams are available, but there doesn't seem to be a whole lot of difference between the two: php://temp supports the stream_select() function and php://memory does not. Which one should I be using in this case, or is there a better way to do memory mapped files in PHP?


回答1:


Straight out of the relevant manual page:

The php://memory wrapper stores the data in the memory. php://temp behaves similarly, but uses a temporary file for storing the data when a certain memory limit is reached (the default is 2 MB).

Source: I went on Google and searched for php temp memory. This was the first result, with the answer in the extract.

php://temp sounds appropriate for your use case.



来源:https://stackoverflow.com/questions/6005342/memory-mapped-files-in-php-what-is-the-difference-between-php-temp-and-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!