Re: Re: how do I use php://memory?

From: Date: Sat, 30 Jan 2010 03:46:47 +0000
Subject: Re: Re: how do I use php://memory?
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-301681@lists.php.net to get a copy of this message
Eric Lee wrote: > On Sat, Jan 30, 2010 at 9:00 AM, Shawn McKenzie <nospam@mckenzies.net>wrote: > >> Mari Masuda wrote: >> >>> Has anyone ever successfully used php://memory before? If so, what >>> can I do to use it in my code? Thank you. >> No, but I was intrigued to try it, so I tested this: >> >> $text = 'Some text.'; >> file_put_contents('php://memory', $text); >> echo file_get_contents('php://memory'); >> >> And it returned nothing. The docs suck on this and it apparently >> doesn't work. I see others use it with fopen(), but there is no mention >> of which file functions it works with and which it doesn't. >> >> > > Shawn > > I did a sample test from the manual with fopen like this, > > > <?php > > $fp = fopen('php://memory', 'r+'); > > if ($fp) > { > fputs($fp, "line 1\n"); > } > > rewind($fp); > echo stream_get_contents($fp); > > ?> > > console output > > F:\wc\trunk>php -f m.php > line 1 > > > > Regards, > Eric, So maybe it only works with an open file/stream resource? Hard to tell with no docs. -- Thanks! -Shawn http://www.spidean.com

« previous php.general (#301681) next »