I'm using in my script very simple template engine:
<?php
require_once('some_class.php');
$some_class = new some_class();
function view($file, $vars) {
ob_start();
extract($vars);
include dirname(__FILE__) . '/' . $file . '.php';
$buffer = ob_get_contents();
ob_end_clean();
return $buffer;
}
echo view('template', array(
'content' => some_class::content(),
'pages' => some_class::pages(),
'meta_title' => some_class::$meta_title,
'meta_description' => some_class::$meta_description
));
?>
It worked well but my script grows bigger and i'm adding new functions and sometimes in some situations it take a lot time to load page. My webpage need to use external API sometime and there are delays. How can i rebuild this to work without output buffering?