php获取print的内容,放入变量

可以参考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

posted on 2014-03-19 22:31  merryfreespace  阅读(271)  评论(0编辑  收藏  举报