Smarty

 上图中,其中Smarty.class.php为主类文件

<?php 

//引入Smarty 
include './Smarty/Smarty.class.php';
//实例化
$s=new Smarty();

//给变量赋值或传值,那小伟传给name,相当于 $this->name='杜伟'
$s->assign('name','小伟');
$s->assign('age','32');


//显示模板文件,把需要编译的html文件作为参数传递进去
$s->display('my.html');
注意,dispaly 编译后,会在目录中创建一个tempates_c一个目录,里面保存的就是my.html编译后的php和html混编代码,

Smarty不会对my.html主文件做任何改变
原文地址:https://www.cnblogs.com/xiaowie/p/14350148.html