欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

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

程序员文章站 2022-03-31 21:50:10
php文件名:dome.php 复制代码 代码如下:

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>