Home >Backend Development >PHP Tutorial >Simple page buffering technology 2_PHP tutorial
My specific implementation example
In order to help everyone have a perceptual understanding, here I give the file-based processing method implemented on my homepage. Only the main processing code, incomplete.
$#@60;?
1 $tmpfile="../tmp/".basename($REQUEST_URI);
2 $tmpfile=str_replace("?", "_", $tmpfile) ;
3 $tmpfile=str_replace("&", "_", $tmpfile);
4 if(file_exists($tmpfile))
5 {
6 $cflag=false;
7 $dtmp=filemtime($tmpfile);
8 $itmp=filemtime($incfile);
9 $cflag=$cflag | ($dtmp $#@60; $itmp);
10 $ctmp=filemtime(basename($PHP_SELF));
11 $cflag=$cflag | ($dtmp $#@60; $ctmp);
12 $ttmp=filemtime("template/content.ihtml" );
13 $cflag=$cflag | ($dtmp $#@60; $ttmp);
14 }
15 else
16 $cflag=true;
17
18 if(!$cflag) //Use existing file
19 {
20 readfile($tmpfile);
21 exit;
22 }
23
24 //Create New file
25 include "template.class.php3";
26
27 $fp=fopen($incfile, "r");
28 $content=fread($fp, filesize ($incfile));
29 fclose($fp);