- 相關(guān)推薦
如何實(shí)現(xiàn)PHP靜態(tài)新聞列表自動(dòng)生成代碼
php 靜態(tài)新聞列表自動(dòng)生成代碼如何實(shí)現(xiàn),怎么操作呢?就跟隨百分網(wǎng)小編一起去了解下吧,想了解更多相關(guān)信息請(qǐng)持續(xù)關(guān)注我們應(yīng)屆畢業(yè)生考試網(wǎng)!
function CreateShtml()
{
ob_start(array("callback_CreateShtml","callback_GoToShtml"));
}
function callback_CreateShtml($buffer)
{
$page = intval(@$_REQUEST["page"]);
$fileName = $_SERVER['DOCUMENT_ROOT'] . dirname($_SERVER['PHP_SELF']) . "/" . basename($_SERVER['PHP_SELF'],".php") . ($page==0 ? "" : "_" . strval($page)) . ".htm";
$fp = fopen($fileName,"wb");
fwrite($fp,$buffer);
fclose($fp);
return $buffer;
}
function callback_GoToShtml($buffer)
{
$page = intval(@$_REQUEST["page"]);
$fileName = basename($_SERVER['PHP_SELF'],".php") . ($page==0 ? "" : "_" . strval($page)) . ".htm";
header("location:" . $fileName);
return $buffer;
}
function GoToShtml()
{
$page = intval(@$_REQUEST["page"]);
$fileName = basename($_SERVER['PHP_SELF'],".php") . ($page==0 ? "" : "_" . strval($page)) . ".htm";
if(file_exists($fileName))
header("location:" . $fileName);
}
function DeleteShtml($fileName=NULL)
{
if(is_null($fileName))
$fileName = $_SERVER['DOCUMENT_ROOT'] . $_SERVER['PHP_SELF'];
if($fileName[0]=="/")
$fileName = $_SERVER['DOCUMENT_ROOT'] . $fileName;
$path = dirname($fileName);
$dir = dir($path);
$patten = "/^" . basename($fileName, ".php") . "(_[0-9]+)?.htm/";
while(($entry = $dir->read())!==false)
{
if(is_file($path . "/" .$entry) && preg_match($patten,$entry))
unlink ($path . "/" . $entry);
}
}
【如何實(shí)現(xiàn)PHP靜態(tài)新聞列表自動(dòng)生成代碼】相關(guān)文章:
php自動(dòng)生成sitemap地圖的代碼10-07
php自動(dòng)生成sitemap地圖的代碼07-31
PHP中如何實(shí)現(xiàn)crontab代碼05-30
PHP列表頁(yè)實(shí)現(xiàn)的方法05-24
php代碼如何實(shí)現(xiàn)命令行執(zhí)行05-19
PHP生成SiteMap文件的代碼09-27