<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<title>标题:{title}</title>
</head>
<body>
<b>此新闻的内容:</b>{content}
</body>
</html>
<?php
//实际应用中很可能是查询数据库取内容。
$rows = array(array("替换标题1","替换内容1"),array("替换标题2","替换内容2"));
$filename = "tmp.htm";
foreach($rows as $id => $val){
$title = $val[0];
$content = $val[1];
$pagename = "测试".$id.".html";
//对文件名的编码,避免中文文件名乱码
$pagename = iconv("UTF-8", "GBK", $pagename);
//读取模板
$tmpfile = fopen($filename,"r");
$string = fread($tmpfile,filesize($filename));
$string = str_replace("{title}",$title,$string);
$string = str_replace("{content}",$content,$string);
fclose($tmpfile);
//写新文件
$newpage = fopen($pagename,"w");
fwrite($newpage,$string);
fclose($newpage);
}
echo "创建成功!";
?>
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有