note 66823 added to function.ob-start
| From: | net_navard at yahoo dot com | Date: | Tue, 30 May 2006 14:09:12 +0000 |
| Subject: | note 66823 added to function.ob-start | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-112541@lists.php.net to get a copy of this message | ||
Hello firends
ob_start() opens a buffer in which all output is stored. So every time you do an echo, the output of
that is added to the buffer. When the script finishes running, or you call ob_flush(), that stored
output is sent to the browser (and gzipped first if you use ob_gzhandler, which means it downloads
faster).
The most common reason to use ob_start is as a way to collect data that would otherwise be sent to
the browser.
These are two usages of ob_start():
1-Well, you have more control over the output. Trivial example: say you want to show the user an
error message, but the script has already sent some HTML to the browser. It'll look ugly, with
a half-rendered page and then an error message. Using the output buffering functions, you can simply
delete the buffer and sebuffer and send only the error message, which means it looks all nice and
neat buffer and send
2-The reason output buffering was invented was to create a seamless transfer, from: php engine ->
apache -> operating system -> web user
If you make sure each of those use the same buffer size, the system will use less writes, use less
system resources and be able to handle more traffic.
With Regards, Hossein
----
Server IP: 66.163.161.117
Probable Submitter: 80.191.134.205 (proxied: 80.191.134.205, 80.191.134.205)
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.ob-start.php
Edit -- http://master.php.net/note/edit/66823
Del: integrated -- http://master.php.net/note/delete/66823/integrated
Del: useless -- http://master.php.net/note/delete/66823/useless
Del: bad code -- http://master.php.net/note/delete/66823/bad+code
Del: spam -- http://master.php.net/note/delete/66823/spam
Del: non-english -- http://master.php.net/note/delete/66823/non-english
Del: in docs -- http://master.php.net/note/delete/66823/in+docs
Del: other reasons-- http://master.php.net/note/delete/66823
Reject -- http://master.php.net/note/reject/66823
Search -- http://master.php.net/manage/user-notes.php