教程集 www.jiaochengji.com
教程集 >  脚本编程  >  php  >  正文 php模板使用实例教程

php模板使用实例教程

发布时间:2023-05-11   编辑:jiaochengji.com
教程集为您提供php模板使用实例教程等资源,欢迎您收藏本站,我们将为您提供最新的php模板使用实例教程资源

<?php
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");
?>

您可能感兴趣的文章:
php模板PHPLIB处理方式
php模版生成html的小例子
php模板使用实例教程
什么是smarty及教程
PHP smarty模板入门教程
PHP中的模板技术
WordPress常用的函数、方法汇总
PHP实现微信模板消息发送给指定用户
用PHP制作静态网站的模板框架
jquery 实现二级导航条效果

[关闭]
~ ~