Posts

Showing posts from May, 2008

Cannot modify header information - headers already sent by

Solution #1 - no output before header(), setcookie() and other header setting functionsThus, the first solution to the "Cannot modify header information" error is to make sure you are not outputting any content at all before the call to the header() function. Solution #2 - ob_start() The second method consists in calling the ob_start() at the very top of the PHP script like this: ob_start(); This will turn output buffering on. With output buffering the entire PHP script will be processed before any output is sent to the client. Thus all the PHP script will be aware of all the header changes and it will not send any headers until every line has been processed.ob_start() may appear to slow down the loading time on server intensive pages, because the client will not be presented with any fragment of the page until the page is fully processed.