php 批量输出静态页面

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
//循环执行以下代码,就批量生成了。文件名循环产生的自定义的有固定格式的
$gid = $_GET['gid']+0;//id

$goods_statis_file = "goods_file_".$gid.".html";//对应静态页文件名

if(file_exists($goods_statis_file)){
unlink($goods_statis_file);//删除之前存在的静态页文件

ob_start(); //开启缓存读取功能
//include ("xxx.html");//加载模板
//从数据库读取数据,并赋值给相关变量
//echo 内容
//include ("xxx.html");//加载模板

$content = ob_get_contents();//把上面输出在缓存的内容赋值给$content变量
file_put_contents($goods_statis_file,$content);//写入内容到对应静态文件中
ob_end_flush();//关闭缓存读取功能

编辑文章✏