欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

php Http_Template_IT類庫(kù)進(jìn)行模板替換

 更新時(shí)間:2009年03月19日 01:29:44   作者:  
php Http_Template_IT模板替換實(shí)現(xiàn)代碼
兩個(gè)簡(jiǎn)單模板:
復(fù)制代碼 代碼如下:

<html>
<head>
<title>{title}</title>
</head>
<body>
<font color=red size=6><center>{title}</center></font>
<hr>
<pre>{body}</pre>
</body>
</html>

復(fù)制代碼 代碼如下:

<html>
<head>
<title>{title}</title>
</head>
<body>
<font color=green size=7><center>{title}</center></font>
<pre>{body}</pre>
</body>
</html>

必須先安裝Http_Template_IT類庫(kù)
復(fù)制代碼 代碼如下:

<?php
require_once "HTML/Template/IT.php";
//創(chuàng)建新的HTML_Template_IT對(duì)象,其中參數(shù)為模版文件所在路徑
$template = new HTML_Template_IT('templates/');
//讀取模版文件,通過讀取地址欄上的參數(shù)獲得模版信息
$template->loadTemplateFile($_GET['template'].".htm");
//設(shè)置模版中的參數(shù)
$template->setVariable('title', 'HTML_Template_IT');
$template->setVariable('body', 'Hello World');
//顯示頁(yè)面
$template->show();
?>

在瀏覽器中寫入如下,會(huì)發(fā)現(xiàn)模板替換效果:
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

相關(guān)文章

最新評(píng)論