PHP生成静态HTML页面最简单方法示例

时间:2021-05-26

PHP文件名:dome.php
复制代码 代码如下:
<?php
$string = 1;
ob_start();
@readfile("templets/list.html");
$text = ob_get_flush();
$myfile = fopen("list.html","w");
$text = str_replace ("{counent}",$string,$text);
fwrite($myfile,$text);
ob_clean();
?>

模板文件名:templets/list.html
复制代码 代码如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>

</body>
<table width="500" border="0" cellpadding="5" cellspacing="1" align="center" bgcolor="#add3ef">
<tr bgcolor="#eff3ff">
<td>用户:{counent_user} 标题:{counent_title} 发布时间:{counent_lastdate}</td>
</tr>
<tr bgcolor="#fff">
<td>内容:{counent_content}</td>
</tr>
</table>
</form>
</html>

声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。

相关文章