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);
}
}
Createshtml ();
echo "This is a statically generated page! $page ";
Gotoshtml ();
Deleteshtml ();
?>
The above describes the sword Spirit November 28 Open Test cache Implementation of static page testing, including the sword Ling November 28 Open Test content, I hope to be interested in PHP tutorial friends helpful.