概述
/**
* Render a system default template, which is essentially a PHP template.
*
* @param $template_file
* The filename of the template to render. Note that this will overwrite
* anything stored in $variables['template_file'] if using a preprocess hook.
* @param $variables
* A keyed array of variables that will appear in the output.
*
* @return
* The output generated by the template.
*/
function theme_render_template($template_file, $variables) {
extract($variables, EXTR_SKIP); // Extract the variables to a local namespace
ob_start(); // Start output buffering
include "./$template_file"; // Include the template file
$contents = ob_get_contents(); // Get the contents of the buffer
ob_end_clean(); // End buffering and discard
return $contents; // Return the contents
}drupal框架中使用的渲染模版的方法 方便前端和逻辑代码分开,一次请求过程可多次调用
最后
以上就是默默高山为你收集整理的php渲染怎么写,PHP渲染模版的的方法的全部内容,希望文章能够帮你解决php渲染怎么写,PHP渲染模版的的方法所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复