Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Brian Moon's Blog:
ob_start and HTTP headers
Feb 01, 2010 @ 20:38:27

Brian Moon has a new post to his blog today looking at something it's common for web applications to use, ob_start, and what about HTTP headers makes it work to prevent the infamous "headers already sent" message.

HTTP is the communication protocol that happens between your web server and the user's browser. Without too much detail, this is broken into two pieces of data: headers and the body. The body is the HTML you send. But, before the body is sent, the HTTP headers are sent.

He includes a sample raw HTTP response for a page and how the ob_start function works to buffer the output of the resulting page to save the header information until the buffer is echoed or cleaned out. There is a down side he mentions, though - there's no partial buffering built in so it's an all or nothing short.

tagged: obstart http header buffer

Link:


Trending Topics: