PHP ob_start()用途

PHP网站上的一条comment,写的非常的好:

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.

 

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

This site uses Akismet to reduce spam. Learn how your comment data is processed.