Home >Backend Development >PHP Tutorial >A fast and easy-to-use PHP paging class
[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." for ($i=0;$i |