Ec (2); php automatically generates html static pages at regular intervals & quot; ob_start (), ob_end_clean (), ob_get_contents () & quot; ob_start (): Enable the buffer zone, it is to cache the content of the static file you need to generate here; ob_get_contents (): Read the content in the buffer zone. The following code is used as an example; ob_end_clean (): this is important, only this function script ec (2) and script
Php automatically generates html static pages at regular intervals
"Ob_start (), ob_end_clean (), ob_get_contents ()"
Ob_start (): it is used to open the buffer, that is, to cache the content of the static file you need to generate here;
Ob_get_contents (): Read the content in the buffer. The following code is used as an example;
Ob_end_clean (): This is important. Only when this function is used can the content in the buffer be read;
[Copy this CODE] CODE:
If (file_exists ("./index.htm") // check whether the static index.htm file exists.
{
Time = time ();
// Is the file modification time different from the current time? Otherwise, the htm file will be generated again.
If (time-filemtime ("./index.htm") <600)
{
Header ("Location: classhtml/main.htm ");
}
}
// Add ob_start () to your start ();
Ob_start ();
// The homepage content is your dynamic part
// Add ob_end_clean () to the end and output this page to a variable.
Temp = ob_get_contents ();
Ob_end_clean ();
// Write a file
Fp = fopen ("./index.htm", 'w ');
Fwrite (fp, temp) or die ('file writing error ');
// Echo "HTML generation complete! ";