Streams are php resources ie global, you just pass handle about.
$fp = fopen("php://memory", 'r+'); // create a handle 
fputs($fp, $payload); // write data to the stream
$total_length=ftell($fp); // get the length of the stream
$payload_chunk = fread ( $fp, $segment_length  );
you can rewind them, or fread into them with offsets, etc.
echo stream_get_contents($fp);
 and fclose them etc.
Keith.

On Thu, 25 Sep 2008 19:07:57 +1200, Aaron Fulton <[EMAIL PROTECTED]>
wrote:
> Take a look at some of the ob_ functions in the php manual
> http://nz.php.net/manual/en/function.ob-get-contents.php
> 
> 
> Philip Arndt wrote:
>> Hi,
>>
>> I'm just wondering if anybody knows of a way to run a function that
>> contains print statements in a mode that will instead "print" to a
>> buffer that I can use inside another function?
>>
>> e.g.
>>
>> function do_something()
>> {
>>      print "{success: true}";
>> }
>>
>> but run this like so:
>>
>> function do_something_else
>> {
>>      $result = print_to_variable(do_something);
>>
>>      print $result . ", {returntype: string}";
>> }
>>
>> Probably a bit of a leftfield request, but that sort of thing is what
>> I'm after.
>>
>> Cheers,
>> Phil
>>
>> >
>> ------------------------------------------------------------------------
>>
>>
>> No virus found in this incoming message.
>> Checked by AVG - http://www.avg.com
>> Version: 8.0.169 / Virus Database: 270.7.1/1687 - Release Date:
> 9/23/2008 6:32 PM
>>
>>
> 
> 

--~--~---------~--~----~------------~-------~--~----~
NZ PHP Users Group: http://groups.google.com/group/nzphpug
To post, send email to [email protected]
To unsubscribe, send email to
[EMAIL PROTECTED]
-~----------~----~----~----~------~----~------~--~---

Reply via email to