Home >Backend Development >PHP Tutorial >How to generate functions for static pages in PHP_PHP Tutorial

How to generate functions for static pages in PHP_PHP Tutorial

WBOY
WBOYOriginal
2016-07-13 10:27:46882browse

How to generate a static page function:

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";//You can modify your static here Page path
fp = fopen(fileName,"wb");
fwrite(fp,buffer);
fclose(fp);
return buffer;
}
?>

Give me an example
Save the above code as static.php
Execute the following page phpfans.php
CODE:[Copy to clipboard] include("static.php");
CreateShtml();
?>



Untitled Document


echo "Welcome to php fans site, http://www.phpfans.net";
?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/815030.htmlTechArticleHow to generate a static page function: ?php function CreateShtml() { ob_start(callback_CteateShtml); } function callback_CteateShtml(buffer ) { page = intval(@_REQUEST[page]); //fileN...
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