php://memory and php://temp [message #170151] |
Wed, 13 October 2010 01:44 |
BKDotCom
Messages: 7 Registered: October 2010
Karma: 0
|
Junior Member |
|
|
http://php.net/manual/en/wrappers.php.php
per the documentation: php://memory and php://temp are both listed
under "Allows Appending"
what am I missing / what's the point?
They only seem to work with read/write modes such as
fopen('php://memory','rw');
closing the handle, or trying to open another handle without closing
the first essentially erase the contents... so what's the point of
fopen('php://memory','a') ?
you'll
a) be appending nothing,
b) no way to read what you just wrote?
sure would be nice if you could
$fh = fopen('php://memory', 'w');
fwrite($fh, 'test string');
fclose($fh);
$fh = fopen('php://memory', 'r');
$result = fgets($fh,2048);
fclose($fh);
echo $result;
|
|
|
Re: php://memory and php://temp [message #170152 is a reply to message #170151] |
Wed, 13 October 2010 03:06 |
Jerry Stuckle
Messages: 2598 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
On 10/12/2010 9:44 PM, BKDotCom wrote:
> http://php.net/manual/en/wrappers.php.php
> per the documentation: php://memory and php://temp are both listed
> under "Allows Appending"
>
> what am I missing / what's the point?
>
> They only seem to work with read/write modes such as
> fopen('php://memory','rw');
>
> closing the handle, or trying to open another handle without closing
> the first essentially erase the contents... so what's the point of
> fopen('php://memory','a') ?
> you'll
> a) be appending nothing,
> b) no way to read what you just wrote?
>
> sure would be nice if you could
>
> $fh = fopen('php://memory', 'w');
> fwrite($fh, 'test string');
> fclose($fh);
>
> $fh = fopen('php://memory', 'r');
> $result = fgets($fh,2048);
> fclose($fh);
> echo $result;
These are temporary "files" - as soon as they are closed, they go away,
as you note. So it really doesn't make any sense to open them other
than for read/write.
Other options are there - but those are just standard options for any
file. It doesn't mean you need to use them.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
|
|
|