我是靠谱客的博主 默默高山,最近开发中收集的这篇文章主要介绍php渲染怎么写,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渲染模版的的方法的全部内容,希望文章能够帮你解决php渲染怎么写,PHP渲染模版的的方法所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

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

评论列表共有 0 条评论

立即
投稿
返回
顶部