search
Homephp教程php手册如何用PHP实现新闻列表自动生成代码的效果

这篇文章主要讲了如何用PHP实现新闻列表自动生成代码的效果,有一定一定的参考价值,感兴趣的朋友可以看看。

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);  
}  
}

【相关教程推荐】

1. php编程从入门到精通全套视频教程
2. php从入门到精通 
3. bootstrap教程

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools