谁有页面缓冲类!

L0ading 2004-05-09 11:36:50
急用
谢谢
...全文
42 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
L0ading 2004-05-09
  • 打赏
  • 举报
回复
这么快!
谢了!
gaofaq 2004-05-09
  • 打赏
  • 举报
回复
<?php

class Lcache {
var $bufferFileName;
var $en;
var $content;
var $limitTime;

function Lcache($LimitTime="600") {
$this->bufferFileName = basename($_SERVER['PHP_SELF'],".php").".buf";
$this->limitTime = $LimitTime;
}

function Start() {
if (!file_exists($this->bufferFileName) || (int)date(time()-@filemtime($this->bufferFileName))>$this->limitTime) {
$this->en = true; // 尚未缓存或已超时
ob_start();
} else {
$this->readBuf();
$this->out();
exit;
}
}

function readBuf() {
$fp = fopen($this->bufferFileName,"r");
$this->content = fread($fp,filesize($this->bufferFileName));
}

function get() {
$this->content = ob_get_contents();
ob_clean();
}

function bufferTo() {
$fp = fopen($this->bufferFileName,"w");
fputs($fp,$this->content);
fclose($fp);
}

function out() {
if ($this->en) {
$this->get();
$this->bufferTo();
}
echo $this->content;
}
}
?>

21,886

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧