|
|
PHP快速模板技术 |
|
|
作者:未知 来源:月光软件站 加入时间:2005-2-28 月光软件站 |
下面只是一点样例,具体点下面的链接下载打包源代码 http://home.nuc.edu.cn/~arcow/display.php?id=108
<?php /************************************** *********冲星************************** *********[email protected]***************** ********http://www.fashionme.net******* **************************************/ //此页是直接显示 //处理好变量的值 $title="这是标题"; $author="这是作者"; $content="这是内容"; $times=date("Y年m月d日"); //调入模板程序模块 include("template.inc"); //创建一个模板实例mytemp $mytemp = new Template("."); //此处.为模板文件当前目录,若模板文件在template目录中就填入template //设置MyFileHandle文件句柄指向我们所要调用的模板文件template.html $mytemp->set_file("MyFileHandle","template.html"); //调用模板的set_var方法,设置模板中的变量title值为$title,author为$author等 $mytemp->set_var("title", $title); $mytemp->set_var("author", $author); $mytemp->set_var("times", $times); $mytemp->set_var("content", $content); //调用模板的parse方法,对MyFileHandle文件句柄所指向的模板文件进行分析,替换其中相应变量 //并把替换结果即完整的HTML文件内容保存在字串变量MyOutput中 $mytemp->parse("MyOutput","MyFileHandle"); // 打印输出结果字串变量MyOutput的值 ,直接输出 $mytemp->p("MyOutput"); ?> 
|
|
相关文章:相关软件: |
|