Re: Output buffering - saving + echoing

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

 



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

I see three options here:

#1 Call ob_start/ob_get_contents/ob_flush and repeat that a *LOT* within
your script, so that you are buffering only a few lines of text at any
given time:
<?php
  $BUFFER = '';
  ob_start();
  echo "Foo!<BR>\n";
  $BUFFER .= ob_get_contents();
  ob_end_flush();

  ob_start();
  echo "Bar!<BR>\n";
  $BUFFER .= ob_get_contents();
  ob_end_flush();
?>

#2
function buffer_print($text){
  global $BUFFER;
  $BUFFER .= $text;
  print($text);
}

You could make #2 more fancy by accepting multiple arguments and using
echo instead of print internally.

#3
Write an extra script that does like this:
<?php
  $file = file($real_url_they_asked_for);
  $BUFFER = implode('', $file);
  echo $file;
?>

#3 is going to be horrible for large pages, however.


It occurs to me that maybe you should tell us WHY you want this, because
there could be existing alternatives outside the scope of PHP that we
could recommend...

Caching servers such as Squid or Accelerators such as Zend Optimizer
spring to mind.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
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