Re: Proposal: php://memory/<id> (& ://temp/<id>)
| From: | Ivan Enderlin @ Hoa | Date: | Thu, 31 Jan 2013 14:38:54 +0000 |
| Subject: | Re: Proposal: php://memory/<id> (& ://temp/<id>) | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-65542@lists.php.net to get a copy of this message | ||
On 31/01/13 15:35, Gustavo Lopes wrote:
On Thu, 31 Jan 2013 14:55:26 +0100, Ivan Enderlin @ Hoa <ivan.enderlin@hoa-project.net> wrote:No. When you do unset($f1), you're closing the file and the memory is reclaimed. That's how it's supposed to be. Ok.I'm not sure what you mean here. Each time you open a php://memory stream, you're working on a new "bucket", right?Yes exact. My bad. But my proposal still persist. Identifying php://memory buckets would be nice to retrieve them. For example:$f1 = fopen('php://memory/foo', 'r+'); fwrite($f1, 'foobar'); unset($f1);$f1prime = fopen('php://memory/foo', 'r+'); rewind($f1); var_dump(stream_get_contents($f1)); // string(6) "foobar"Is it interesting? In this way, we have a similar behavior than php://fd/<i>, file://, http:// etc.
Just pass the stream along. If you really need to use operations on the URLs themselves, you can easily write a user wrapper that delegates to static php://memory streams kept statically. That's what I did.Thank you for the clarification. -- Ivan Enderlin Developer of Hoa http://hoa-project.net/ PhD. student at DISC/Femto-ST (Vesontio) and INRIA (Cassis) http://disc.univ-fcomte.fr/ and http://www.inria.fr/ Member of HTML and WebApps Working Group of W3C http://w3.org/