该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
//Page.class.php类文件
//分页类
class Page {
private $_total; //总记录数
private $_pagesize; //每页显示记录数
private $_pagenum; //从哪一页开始显示
private $_url; //当前页面地址
private $_both_num; //两边显示的条数
private $_limit; //limit
private $_page; //当前页码
private $_get; //接收get传过来的值
private $_pageshow; //对外显示的分页效果
private $_pagesum; //总页数
private $_index; //是否显示首页和尾页
public function __set($key,$value){
$this->$key=$value;
}
public function __get($key){
return $this->$key;
}
//构造函数初始化
public function __construct($total,$get,$pagesize=10,$both_num=2,$index=1){
$this->getTotal($total);
$this->_get=$get;
$this->_pagesize=$pagesize;
$this->_pagesum=ceil($this->_total/$this->_pagesize);
$this->_page=$this->getPage();
$this->_pagenum=($this->_page-1)*$this->_pagesize;
$this->_limit="limit ".$this->_pagenum.",".$this->_pagesize;
$this->_url=$this->getUrl();
$this->_both_num=$this->getBothNum($both_num);
$this->_index=$index;
}
//获取总记录数
private function getTotal($total){
if($total<=0){
$this->_total=1;
}else{
$this->_total=$total;
}
}
//获取当前页码
private function getPage(){
if(!empty($this->_get)&&is_numeric($this->_get)){
if($this->_get>0){
$this->_get=ceil($this->_get);
if($this->_get>$this->_pagesum){
return $this->_pagesum;
}else{
return $this->_get;
}
}else{
return 1;
}
}else{
return 1;
}
}
//获取当前页面除去page之后的地址
private function getUrl(){
$url=$_SERVER['REQUEST_URI'];
$url=parse_url($url);
if(!empty($url['query'])){
$url_arr=explode('&',$url['query']);
if(count($url_arr)>1){
array_pop($url_arr);