Home >Backend Development >PHP Tutorial >A fast and easy-to-use PHP paging class

A fast and easy-to-use PHP paging class

WBOY
WBOYOriginal
2016-07-25 09:10:35994browse
[code]

totalpage=$objpage; } //Set the current page function setCurrentpage($objpage=1){ $this->currentpage=$objpage; } //Set span function setStride($objStride=1){ $this->stride=$objStride; } //Get the total number of pages function getTotalpage(){ return $this->totalpage; } //Get span read function getStride($objStride=1){ return $this->stride; } //Get the current page function getCurrentpage($objpage=1){ return $this->currentpage; } //print pagination public function Pageprint(){ for($Tmpa=1;$Tmpatotalpage;$Tmpa++){ if($Tmpa+$this->stridecurrentpage){//If the span is added and the span is smaller than the current page, it will not be displayed. continue; } if($Tmpa+$this->stride==$this->currentpage){//Just enough pages to span $p=$this->currentpage-1; $willprint.="Homepage Previous page "; } if($Tmpa>$this->currentpage+$this->stride){//A page larger than the current page + span break; } $willprint.="[$Tmpa]"; if($Tmpa==$this->currentpage+$this->stride){//Just enough pages to span $p=$this->currentpage+$this->stride+1; $willprint.="next page totalpage">last page"; } } echo $willprint; } }

class cut_page extends Page { var $filename; var $showtotal; function __construct($filename){ $this->cachefile = $filename; $this->showtotal = "yes"; } public function filename(){ if (file_exists($this->cachefile)){ return 1; } else return 0; } private $type; public function typelist($typeid){ $this->type = $typeid; $fp = fopen($this->cachefile,"rb"); $str= fread($fp,filesize($this->cachefile)); //echo $this->type."
"; //Category ID $arr= explode("::",$str);

for ($i=0;$itype){ //return $arr2[1]; if(isset($_GET



Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn