Before you start, mention the three functions: "Ob_start (), Ob_end_clean (), ob_get_contents ()"
Ob_start (): is to open the buffer, is to put the static file you need to generate the contents of the cache here;
Ob_get_contents (): is to read out the contents of the buffer, the following code for example;
Ob_end_clean (): This is more important, only after using this function, the contents of the buffer will be read out;
Copy CodeThe code is as follows:
if (File_exists ("./index.htm"))//See if the static index.htm file exists
{
Time=time ();
File modification time and current time difference?, direct-oriented HTM file, otherwise regenerate HTM
if (Time-filemtime ("./index.htm") < 600)
{
Header ("location:classhtml/main.htm");
}
}
Add Ob_start () at the beginning of your service;
Ob_start ();
The content of the homepage is your dynamic part.
Add Ob_end_clean () at the end and output this page to a variable
Temp=ob_get_contents ();
Ob_end_clean ();
Write file
Fp=fopen ("./index.htm", ' W ');
Fwrite (Fp,temp) or Die (' Write file error ');
echo "Generate HTML complete! ";
http://www.bkjia.com/PHPjc/319765.html www.bkjia.com true http://www.bkjia.com/PHPjc/319765.html techarticle before you start, mention the three functions: "Ob_start (), Ob_end_clean (), ob_get_contents ()" Ob_start (): Is the buffer to open, is to put the static file you need to generate the content of the slow ...