如何生成靜態頁面的函數:
<?php
function CreateShtml()
{
ob_start("callback_CteateShtml");
}
function callback_CteateShtml(buffer)
{
page = intval(@_REQUEST["page"]);
//fileName = _SERVER['DOCUMENT_ROOT'] . dirname(_SERVER['PHP_SELF']) . "/article/" . basename(_SERVER['PHP_SELF'],".php") . (page==0 ? "" : "_" . strval(page)) . ".html";
fileName = basename(_SERVER['PHP_SELF'],".php") . (page==0 ? "" : "_" . strval(page)) . ".html";//可以在這裡修改你的靜態頁面路徑
fp = fopen(fileName,"wb");
fwrite(fp,buffer);
fclose(fp);
return buffer;
}
?>舉個例
把上面的代碼保存為 static.php
執行下面頁面 phpfans.php
CODE:[復制到剪切板]<?php
include("static.php");
CreateShtml();
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>無標題文檔</title>
</head><body>
<?php
echo "php愛好者站歡迎你,http://www.phpfans.net";
?>
</body>
</html>