I just recently started toying with output buffering and seem to have run into a roadblock. My website utilizes a template system that loads html header/footer and the correct content template. Problem is the html headers are set in the first template loaded. So when (if) another template is loaded that contains headers (stored in a string $headers) it won't add them to the header. I have created a real sloppy way of doing this, I am looking for suggestions on to better handle this.
index.php
ob_start('ob_html_headers');
the callback function
function ob_html_headers($buffer)
{
global $headers;
return str_replace('</head>', $headers.'</head>', $buffer);
}
Any help is appreciated.