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.