Posted on November 22, 2010
We canâ€™t use header() function in the middle of a page in php. header() function is used for redirection. If the page prints something before this function then we get a message like â€œheader already sent byâ€¦.blablablaâ€.
But we have another way to use header() function in anywhere of a page. We have to use two more function to make it working perfectly. Those two are: ob_start() in the first line of a page a and ob_flush() in the last line of that page We can omit the second one but there are some problem. I will discuss it later.
So, the final syntax is:
This is one type of buffering. The server will buffer all the content and then print together. If there is any header() function then it works first. But of course keep it in mind that, this method will increase program run-time. So, enjoy.
Any comments are appreciatedâ€¦