Rumah  >  Artikel  >  pembangunan bahagian belakang  >  php Http_Template_IT类库进行模板替换_PHP教程

php Http_Template_IT类库进行模板替换_PHP教程

WBOY
WBOYasal
2016-07-21 15:46:51886semak imbas

两个简单模板:

复制代码 代码如下:



{title}


{title}



{body}




复制代码 代码如下:



{title}


{title}

{body}




必须先安装Http_Template_IT类库
复制代码 代码如下:

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

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/320061.htmlTechArticle两个简单模板: 复制代码 代码如下: html head title{title}/title /head body font color=red size=6center{title}/center/font hr pre{body}/pre /body /html 复制代码 代码...
Kenyataan:
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn