您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

PHP实现适用于文件内容操作的分页类,_PHP教程

2024/7/6 10:35:12发布24次查看
php实现适用于文件内容操作的分页类,本文实例为大家分享了php实现文件内容操作的分页类,强调一下只针对文件的操作,供大家参考,具体内容如下
file = file_get_contents($file); $this->pagelen = $len; $this->current = isset($_get['page'])?$_get['page']:1; $this->totalpage = $this->gettotalpage(); $this->url = $this->geturl(); } //获取到这个文件总的长度 private function gettotalpage(){ return ceil(strlen($this->file)/$this->pagelen); } //获取当前传递的参数,保留参数,page参数动态变化 private function geturl(){ $url =parse_url($_server['request_uri']); parse_str($url['query'],$queryarr); unset($queryarr['page']); $querystr = http_build_query($queryarr); return $url['path'].'?'.$querystr.'&page='; } //首页 private function first(){ if($this->current>1) return url.1'>首页; } //上一页 private function pre(){ if( $this->current > 1 ) return url.($this->current-1).'>上一页; } //下一页 private function next(){ if( $this->current totalpage) return url.($this->current+1).'>下一页; } //最后一页 private function end(){ if( $this->current totalpage ) return url.$this->totalpage.'>末页; } public function pagelist(){ $pageliststr = ''; for ($i=1;$itotalpage;$i++){ if($i==$this->current){ $pageliststr.=.$i. ; }else{ $pageliststr.=url.$i.'>.$i. ; } } return $pageliststr; } public function pagestyle($style=1){ switch ($style){ case 1: return 共有.$this->totalpage.页.$this->first().$this->pre().$this->pagelist().$this->next().$this->end(); break; case 2; return $this->pagelist(); break; } } public function getcontents(){ $prepagelen = strlen($this->substrs($this->current-1)); $currentpagelen = strlen($this->substrs($this->current)); return substr($this->file, $prepagelen,$currentpagelen-$prepagelen); } public function substrs($page){ $string = ''; $len= $page*$this->pagelen; for( $i=0; $ifile,$i,1))>0xa0 ){ $string .= substr($this->file,$i,3); $i = $i+2; }else{ $string .= substr($this->file, $i,1); } } return $string; } }
精彩专题分享:php分页功能操作
以上就是本文的全部内容,希望对大家学习php程序设计有所帮助。
http://www.bkjia.com/phpjc/1136636.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/1136636.htmltecharticlephp实现适用于文件内容操作的分页类, 本文实例为大家分享了php实现文件内容操作的分页类,强调一下只针对文件的操作,供大家参考,具...
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product