php Http_Template_IT类库进行模板替换
2018-10-12 14:08
615 查看
两个简单模板:
必须先安装Http_Template_IT类库
在浏览器中写入如下,会发现模板替换效果:
http://localhost:8082/file:/F:/php/phpcode/23/23.4.3/23.4.3.php?template=T2
http://localhost:8082/file:/F:/php/phpcode/23/23.4.3/23.4.3.php?template=T1
<html>
<head>
<title>{title}</title>
</head>
<body>
<font color=red size=6><center>{title}</center></font>
<hr>
<pre>{body}</pre>
</body>
</html>
<html>
<head>
<title>{title}</title>
</head>
<body>
<font color=green size=7><center>{title}</center></font>
<pre>{body}</pre>
</body>
</html>
必须先安装Http_Template_IT类库
<?php
require_once "HTML/Template/IT.php";
//创建新的HTML_Template_IT对象,其中参数为模版文件所在路径
$template = new HTML_Template_IT('templates/');
//读取模版文件,通过读取地址栏上的参数获得模版信息
$template->loadTemplateFile($_GET['template'].".htm");
//设置模版中的参数
$template->setVariable('title', 'HTML_Template_IT');
$template->setVariable('body', 'Hello World');
//显示页面
$template->show();
?>
在浏览器中写入如下,会发现模板替换效果:
http://localhost:8082/file:/F:/php/phpcode/23/23.4.3/23.4.3.php?template=T2
http://localhost:8082/file:/F:/php/phpcode/23/23.4.3/23.4.3.php?template=T1
您可能感兴趣的文章:
相关文章推荐
- php Http_Template_IT类库进行模板替换
- php运用Http_Template_IT类库进行模板替换
- php auth_http类库进行身份效验
- php运用auth_http类库进行身份效验
- PHP设计模式:模板Template模式
- Opencv使用cv::matchTemplate进行模板匹配
- Php设计模式之【模板方法模式Template Method Pattern 】
- 【转】ASIHTTPRequest开源类库进行http请求
- PhpStorm Live Template加PHP短语法Short Open Tags打造原生模板
- 函数模板(Function Template)及带默认参数的函数 http://blog.chinaunix.net/xmlrpc.php?r=blog/article&uid=25520556&id
- EmguCV Image类中的函数(四)使用MatchTemplate函数进行模板匹配
- (转)模板引擎类dedetemplate.class.php使用说明
- 获取远程数据类库:Http Requests for PHP
- 批处理命令进行模板文件的替换
- 使用PHP进行HTTP重定向(301,302)
- iOS网络通信类库用AFNetworking替换ASHttpRequest的解决方案
- PHP - 使用pear的HTTP_Upload包进行上传
- [WPF系列]-数据邦定之DataTemplate 对 ItemsControl 进行样式和模板处理
- Atitit.eclipse comment template注释模板