糯米文學吧

位置:首頁 > 計算機 > php語言

PHP生成靜態HTML頁面最簡單方法示例

php語言1.52W

PHP生成靜態HTML頁面最簡單方法來分享給大家,跟隨小編去看看吧!

PHP生成靜態HTML頁面最簡單方法示例

PHP文件名:

  複製代碼 代碼如下:

<?php

$string = 1;

ob_start();

@readfile("templets/");

$text = ob_get_flush();

$myfile = fopen("","w");

$text = str_replace ("{counent}",$string,$text);

fwrite($myfile,$text);

ob_clean();

?>

模板文件名:templets/

複製代碼 代碼如下:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">

<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></p