将 PHP社区动力 设为主页首页 资讯 论坛 | 站长工具 | ip查询

推荐给好友 上一篇 | 下一篇

php使用smarty 生成静态页

在一些负载高的项目中有时需要将一些动态页面生成静态页的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 静态
 

评分:0

我来说两句