在一些负载高的项目中有时需要将一些动态页面生成静态页的html 以达到减轻服务器负载的目的。使用Smarty可以通过以下方法实现。
$smarty->display("index.html.php"); //这句注释掉,加以下语句
$output = $smarty->fetch("index.html.php");
$pagename = "index.html"; //静态页路径
$fp = fopen($pagename,"w");
fwrite($fp,$output);
fclose($fp);
看看你的站点目录是不是多了个index.html的静态页文件呢。
TAG: PHP php Smarty smarty 静态
