Re: Proposal: php://memory/<id> (& ://temp/<id>)

From: Date: Thu, 31 Jan 2013 14:35:14 +0000
Subject: Re: Proposal: php://memory/<id> (& ://temp/<id>)
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-65541@lists.php.net to get a copy of this message
On Thu, 31 Jan 2013 14:55:26 +0100, Ivan Enderlin @ Hoa <ivan.enderlin@hoa-project.net> wrote:
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.
No. When you do unset($f1), you're closing the file and the memory is reclaimed. That's how it's supposed to be. 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. -- Gustavo Lopes

« previous php.internals (#65541) next »