最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
php模板使用实例教程
时间:2022-07-02 10:47:06 编辑:袖梨 来源:一聚教程网
include ('template.inc'); //包含模板类 template.inc
//创建一个实例
$tpl = new Template("template");
//读入三个模板文件的内容,分别给变量"main", " child_header", " child_footer"
$tpl->set_file("main", "NestingMain.html");
$tpl->set_file("child_header", "NestingHeader.html");
$tpl->set_file("child_footer", "NestingFooter.html");
//将模板child_header, child_footer里的模板变量替换,并把最终结果分别赋给主模板中的header,footer
$var_array = array('title'=>'标题:表格的属性',
'author'=>'kiki',
);
//可以传递数组
$tpl->set_var($var_array);
$tpl->parse("header", "child_header");
$tpl->parse("footer", "child_footer");
//然后完成主模板内变量的替换,并输出主模板分析后的内容
$tpl->parse("myout", "main");
//输出
$tpl->p("myout");
?>
相关文章
- 《弓箭传说2》新手玩法介绍 01-16
- 《地下城与勇士:起源》断桥烟雨多买多送活动内容一览 01-16
- 《差不多高手》醉拳龙技能特点分享 01-16
- 《鬼谷八荒》毕方尾羽解除限制道具推荐 01-16
- 《地下城与勇士:起源》阿拉德首次迎新春活动内容一览 01-16
- 《差不多高手》情圣技能特点分享 01-16