可以参考drupal的theme_render_template函数
function theme_render_template($template_file, $variables) {
//
Extract the variables to a local namespace
extract($variables,
EXTR_SKIP);
// Start output buffering
ob_start();
// Include the template file
include
DRUPAL_ROOT . ‘/‘ . $template_file;
// End buffering and return
its contents
return ob_get_clean();
}
主要用到2个函数,ob_start和ob_get_clean