|
|
|
|
Ever seen the error "Headers cannot be sent, output started blah blah bla"? Ever wonder why it is happening?
What happenes with a PHP page once it has been requested is that it will send output to the browser as it becomes available. So in order for the browser to process the info it needs the headers which are the first thins sent.
echo "howdy";
header("location: anotherpage.php");
Will generate that error.
So how do you get round it? Well you could format the page not to output anything until all header manipulation is done.
It is very simple. To solve thw problem we use output buffering.
ob_start();
echo "howdy";
header("location: anotherpage.php");
ob_end_flush();
Now what happens is that php buffers all the info. Once you flush the buffer, the properly formatted HTML document is sent to the browser.
There are many other output buffering functions available in php but these are the essentials.
|
|
|
|
|
|