Re: Output buffering - saving + echoing

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Not exactly sure what your question is. You want to catch the buffer, but don't delay the buffer to be sent???
If your question is that you want to hold the contents of the buffer and send it only when you are ready, don't use ob_end_flush, use ob_end_clean. The buffer is cleared without sending anything to the client. The buffer contents are still retained in the variable $buf. When you are ready, you can just echo $buf.


The biggest advantage to output buffering, from a client server view, is that the contents can be compressed before sending to the client if the client supports compression (most browsers do). You'll get the best performance when you send everything at once instead of piecemeal.

On Dec 14, 2004, at 9:01 PM, Lorderon wrote:

Hi,

When using ob_start(), the output is buffered and not sent till
ob_end_flush() is called or got to end of the script. Also before flushing
you can get the buffer contents by ob_get_contents().


<?
//start buffering, from now on no output.
//NEED: start buffering, but output imediatly when echo.
ob_start();

//this is not echoed now.
//NEED: echo this now, but still buffer it too.
echo "Hello, World!";

//getting the buffer contents.
//NEED: getting the buffer contents.
$buf=ob_get_contents();

//the buffer is echoed just now.
//NEED: stop the buffering, and not output all the buffer now.
ob_end_flush();
?>

What I want to do is "catch" the output buffer, but do not delay the buffer
to be sent. How is it done?



thanks in advance, Lorderon.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


--
Brent Baisley
Systems Architect
Landover Associates, Inc.
Search & Advisory Services for Advanced Technology Environments
p: 212.759.6400/800.759.0577

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux