封裝分頁類

2021-07-02 20:54:50 字數 909 閱讀 4082

<?php

class pageelse

if($this->total<=0)else

}function showpage()

//print_r($parse_url['query']);

parse_str($parse_url['query'],$parms);

if(!array_key_exists('page',$parms))

if(count($parms)==1)else

$prev=$this->currentpage-1;

$next=$this->currentpage+1;

$header='首頁';

$last='countpage . '">尾頁';

if($prev<1)else

if($next>$this->countpage)else

$start = $this->currentpage - (5-1)/2; //計算左側開始的頁碼

$end = $this->currentpage + (5-1)/2;

//計算右側開始的頁碼

//如果左側的頁面,已經小於1,則把小於1 的部分補到右側

if ($start < 1)

}//把右側超出的部分,補到左邊

if ($end > $this->countpage)

}$pagestr='';

for ($i=$start; $i <= $end ; $i++)

$pagestr.='' . $i . '';

}return $header.$prevpage.$pagestr.$nextpage.$last;}}

$page=new page(30,3);

echo $page->showpage();

?>

分頁封裝成類

private function setlimit private function geturi pa return url private function get args private function start private function end private function...

分頁工具類的封裝

public class pageabletools 獲取基礎分頁物件,每頁條數預設15條 預設以id降序排序 param page 獲取第幾頁 return public static pageable basicpage integer page 獲取基礎分頁物件,每頁條數預設15條 param...

分頁工具類的封裝

public class pageabletools 獲取基礎分頁物件,每頁條數預設15條 預設以id降序排序 param page 獲取第幾頁 return public static pageable basicpage integer page 獲取基礎分頁物件,每頁條數預設15條 param...