FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » php://memory and php://temp
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
php://memory and php://temp [message #170151] Wed, 13 October 2010 01:44 Go to next message
BKDotCom is currently offline  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 Go to previous message
Jerry Stuckle is currently offline  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
==================
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Adding MSSQL support to a MySQL/Postgres script
Next Topic: problem with session cleanup
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Wed Nov 27 08:34:02 GMT 2024

Total time taken to generate the page: 0.02250 seconds