As the header and footer never change, I was trying to use output buffering to buffer all the content and then use my own function to output the content within the predefined header/footer. This is working except that its outputting the header and footer twice, once with the content in between and again without and I have no idea why! This is the function I have for flushing the buffer:
function ob_output($buffer) {
GLOBAL $site;
$header = file_get_contents(INC_PATH . 'header.inc.php');
$footer = file_get_contents(INC_PATH . 'footer.inc.php');
$output = $header . $buffer . $footer;
foreach( $site as $k => $v ) {
$output = str_replace('[['.$k.']]',$v,$output);
}
return $output;
}
I know using global $site is not ideal, and I will fix that using constants and get_defined_constants but I was just trying to get this working first. I thought maybe it was the call for FGC for some reason but if i don't concantenate the 3 variables and just use $output = $buffer then the header footer doesn't show at all. If i do $output = $buffer . $footer i get the footer twice and the buffer once, same if i do = $header . $buffer. I'm completely lost!