PHP批量生成静态HTML的例子
浏览量:138
why:
how:
if($_POST[button]){
$sql="select * from doorsjk_about where id<12";
$rs=$db->query($sql);
while($row=$db->fetch_array($rs)){
$path='list12'.$row[id].'.html';
$fp=fopen("../group/about.html","r");
$str=fread($fp,filesize("../group/about.html"));
$str=str_replace("{title}",$row[title],$str);
$str=str_replace("{name}",$system['name'],$str);
$str=str_replace("{content}",$row[content],$str);
$str=str_replace("{copyright}",$system['copyright'],$str);
fclose($fp);
$handle=fopen("../group/".$path,"w");
fwrite($handle,$str);
echo "<font color='red'>正在生成</font>";
echo "$path";
fclose($handle);
}
echo "<script>alert('生成成功!');window.location.href='Onlyhtml.php';</script>";
}
?>
<form id="form1" name="form1" method="post" action="">
<label><div style="margin:200px 200px;"><img src="../images/html.jpg" />
<input type="submit" name="button" id="button" value="单页生成" />
</div>
</label>
</form>

感谢支持与鼓励~