我是靠谱客的博主 幸福冬瓜,这篇文章主要介绍PHP渲染模版的的方法,现在分享给大家,希望可以做个参考。

/**
 * 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渲染模版内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(105)

评论列表共有 0 条评论

立即
投稿
返回
顶部