bahaa Posted May 6, 2012 Share Posted May 6, 2012 Hello, How do I get rid of the output buffering already sent ? I need to generate the page title dynamically and this require to echo it before the header and it causes the the output buffer already sent to appear. I also use the header() function in many places in my code. I can't change the setting on the server because it is shared hosting. Bahaa, Link to comment Share on other sites More sharing options...
HartleySan Posted May 6, 2012 Share Posted May 6, 2012 What about moving all the header function calls to before any HTML is output? Link to comment Share on other sites More sharing options...
Edward Posted May 7, 2012 Share Posted May 7, 2012 Hello, How do I get rid of the output buffering already sent ? I need to generate the page title dynamically and this require to echo it before the header and it causes the the output buffer already sent to appear. I also use the header() function in many places in my code. I can't change the setting on the server because it is shared hosting. Bahaa, This problem can be solved by omitting the closing php tags at the bottom of scripts. Possibly i could be wrong but since i started i will add the other info i found: Omit the closing PHP tag (?>) in files that contain only PHP code. The closing PHP tab is optional, provided nothing else (e.g., HTML) comes after the PHP code. Leaving out the closing tag has the advantage of preventing unwanted whitespace triggering the "headers already sent" error when using includes. Link to comment Share on other sites More sharing options...
Paul Swanson Posted May 7, 2012 Share Posted May 7, 2012 Use one of the output control functions: http://www.php.net/manual/en/ref.outcontrol.php. It sounds like you want to use ob_clean() to erase the current buffer, but if you also want to turn off buffering, use ob_end_clean(). 2 Link to comment Share on other sites More sharing options...
Recommended Posts