Posted in PHP onMarch 19, 2007
<?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
<?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 "三水点靠木欢迎你,https://3water.com"; ?> </body> </html>
将会生成一个 phpfans.html的静态页面
如果有参数,则用page来传递 如 phpfans.php?page=1
则生成 phpfans_1.html的静态页面
生成静态页面的php函数,php爱好者站推荐
声明:登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。
Reply on: @reply_date@
@reply_contents@