php全世界最小最简单的模板引擎------pain (普通版),不同于smarty,所有的变量以{@ @}括起来,有助于大家对模板引擎的了解。
打包下载
Pain.php
var[$variable]=$value;
}
public function display($template_name,$return_string=false)
{
//first find whether the tmp file in tmp dir exists.
if(file_exists("tmp/temp_file.php"))
{
unlink("tmp/temp_file.php");
}
extract($this->var);
$tpl_content=file_get_contents($template_name);
$tpl_content=str_replace("{@", "", $tpl_content);
//create a file in the /tmp dir and put the $tpl_contentn into it, then
//use 'include' method to load it!
$tmp_file_name="temp_file.php";
//$tmp is the handler
$tmp=fopen("tmp/".$tmp_file_name, "w");
fwrite($tmp, $tpl_content);
include "tmp/".$tmp_file_name;
}
}
?>test.php
易通(企业网站管理系统)是一款小巧,高效,人性化的企业建站程序.易通企业网站程序是国内首款免费提供模板的企业网站系统.§ 简约的界面及小巧的体积:后台菜单完全可以修改成自己最需要最高效的形式;大部分操作都集中在下拉列表框中,以节省更多版面来显示更有价值的数据;数据的显示以Javascript数组类型来输出,减少数据的传输量,加快传输速度。 § 灵活的模板标签及模
assign("songyu",$songyu);
$pain->assign("zhangyuan",$zhangyuan);
$pain->display("new_file.html");
?>new_file.html
new_file {@$songyu@}
{@$zhangyuan@}








