You can have a render function like:
function render ($template, array $environment = array()) {
extract($environment);
ob_start();
include $template;
$contents = ob_get_clean();
return $content;
}
The extract()
function will import all variables from the array into the current scope making them available to your template.
http://nl1.php.net/manual/en/function.extract.php
ob_start()
will buffer all content from that point onwards.
ob_get_clean()
will get the contents of the buffer end ends the buffering of output.