Re: Differences between echoing the output gradually or returning it.

From: Date: Thu, 23 Sep 2004 00:26:08 +0000
Subject: Re: Differences between echoing the output gradually or returning it.
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-197636@lists.php.net to get a copy of this message
On Wed, 22 Sep 2004 22:10:07 +0000, Eduard Duran i Rosich <iopahopa@gmail.com> wrote: > I just wanted to know what are the main pros and cons between echoing > the output some PHP script as it process the data and returning the > whole output to echo it at once. > I find the second way to be useful when I want to add a header() line > without concerning former output. > However, is that way slower or has any other inconvenience? I always build up the HTML and output it at the end. That way I can optimize it, removing all the line breaks and tabs. I always use output compression so it helps two-fold. Of course I can't do that in every situation, it messes with line breaks in <textarea> fields for instance. There are two buffering mechanisms at work when you make a page request. The web server sending the data and the web client receiving the data. You can control the former to some extent with PHP's output buffering functions. I have always found it problematic at best to try and control the web client's internal buffering. In addition, if you output a <table> tag, some browsers will not render the table or the entire page until the closing </table> is received. Which way is faster depends on what the script does more than how you output it. Try it both ways, bench it, and then you'll know for sure. -- Greg Donald http://gdconsultants.com/ http://destiney.com/

« previous php.general (#197636) next »