Chinaunix首页 | 论坛 | 博客
  • 博客访问: 14424698
  • 博文数量: 5645
  • 博客积分: 9880
  • 博客等级: 中将
  • 技术积分: 68081
  • 用 户 组: 普通用户
  • 注册时间: 2008-04-28 13:35
文章分类

全部博文(5645)

文章存档

2008年(5645)

我的朋友

分类:

2008-04-28 20:31:31

下载本文示例代码
我的具体实现的例子   为了帮助大家有个感性认识,这里我给出在我的主页上实现的基于文件处理的方法。只有主要的处理代码,不完整。 $#@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) //使用存在的文件 19 { 20 readfile($tmpfile); 21 exit; 22 } 23 24 //创建新的文件 25 include "template.class.php3"; 26 27 $fp=fopen($incfile, "r"); 28 $content=fread($fp, filesize($incfile)); 29 fclose($fp); 30 31 //下面进行模版处理 32 $t = new Template("template", "keep"); 33 34 $t-$#@62;set_file("contentfile","content.ihtml"); 35 36 $t-$#@62;set_var( 37 array( 38 "content"=$#@62;$content 39 )); 40 41 $t-$#@62;parse("outputcontent","contentfile"); 42 43 $fp=fopen($tmpfile, "w"); 44 if($fp) 45 { 46 flock($fp, 3); 47 fwrite($fp, $t-$#@62;get_var("outputcontent")); 48 flock($fp, 1); 49 fclose($fp); 50 } 51 $t-$#@62;p("outputcontent"); ?$#@62;   先向大家介绍一下我的目录结构:   /---bin/ 执行程序目录   | |--content.php3 用于处理文件显示的程序    | |--template/ 用于存放模板文件的目录    | |---content.ihtml 模板文件    |-docs/ 数据文件    |-tmp/ 存放缓冲文件 我的具体实现的例子   为了帮助大家有个感性认识,这里我给出在我的主页上实现的基于文件处理的方法。只有主要的处理代码,不完整。 $#@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) //使用存在的文件 19 { 20 readfile($tmpfile); 21 exit; 22 } 23 24 //创建新的文件 25 include "template.class.php3"; 26 27 $fp=fopen($incfile, "r"); 28 $content=fread($fp, filesize($incfile)); 29 fclose($fp); 30 31 //下面进行模版处理 32 $t = new Template("template", "keep"); 33 34 $t-$#@62;set_file("contentfile","content.ihtml"); 35 36 $t-$#@62;set_var( 37 array( 38 "content"=$#@62;$content 39 )); 40 41 $t-$#@62;parse("outputcontent","contentfile"); 42 43 $fp=fopen($tmpfile, "w"); 44 if($fp) 45 { 46 flock($fp, 3); 47 fwrite($fp, $t-$#@62;get_var("outputcontent")); 48 flock($fp, 1); 49 fclose($fp); 50 } 51 $t-$#@62;p("outputcontent"); ?$#@62;   先向大家介绍一下我的目录结构:   /---bin/ 执行程序目录   | |--content.php3 用于处理文件显示的程序    | |--template/ 用于存放模板文件的目录    | |---content.ihtml 模板文件    |-docs/ 数据文件    |-tmp/ 存放缓冲文件 下载本文示例代码


简单的页面缓冲技术(二)简单的页面缓冲技术(二)简单的页面缓冲技术(二)简单的页面缓冲技术(二)简单的页面缓冲技术(二)简单的页面缓冲技术(二)简单的页面缓冲技术(二)简单的页面缓冲技术(二)简单的页面缓冲技术(二)简单的页面缓冲技术(二)简单的页面缓冲技术(二)简单的页面缓冲技术(二)简单的页面缓冲技术(二)简单的页面缓冲技术(二)简单的页面缓冲技术(二)
阅读(107) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~