Re: output buffering
| From: | Christian Dechery | Date: | Fri, 06 Apr 2001 01:55:36 +0000 |
| Subject: | Re: output buffering | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-47373@lists.php.net to get a copy of this message | ||
At 00:26 5/4/2001 -0500, Plutarck wrote:
http://www.php.net/manual/en/ref.outcontrol.php If you want to use output buffering you must use the ob_* family of functions. In any script where you want it used you _must_ use it explicitly, or so do in an included file. Unless you can change the php.ini, there is no way to force all pages to use output buffering. I don't reccommend you do such a thing anyway. If you aren't using output compression all it does is allow bad programming practices. One exception is for hosting companies that want to force ads to be displayed on the page with the auto_prepend type settings. Output buffering should only be used if you have a specific reason for doing so. Kind of like all PHP functions :) It doesn't cost much in performance except when a script pumps out a very large amount of data. If you want to print a 10mb text file to the browser it is a considerably _BAD_ idea to force PHP to buffer that all up into one chunk before puking it out. But, enter the gz_handler functions. If you want to compress your output, then you have a reason for using output buffering. The cost in performance varies widely, but if your server is already under a considerable load you probably shouldn't use it. But it's very cool to use if you have the extra processor power, but wait for 4.0.5 to do it. Many people complain about memory leaks and sub-standard output buffering functions. It's supposed to all be fixed in the new version, so feel free to play around with it :) Still, it's better to be able to set it only in the places you want it run rather than making all output use it.exactly... I don't want to set this option to an entire site just because of one little script I'm having trouble setting a header() or setcookie()... and I wanna use them in the middle of the output... something like ASP's <% response.flush=true %>, it can be set anywhere u want... but of course... the best way is to code right and not to mess with headers once the output has started... but sometimes I wish I could, u know? It would really make somethings a lot simpler... ____________________________ . Christian Dechery (lemming) . http://www.tanamesa.com.br . Gaita-L Owner / Web Developer