PHP封装分页类-创新互联
PHP封装分页类?很多新手对此不是很清楚,为了帮助大家解决这个难题,下面小编将为大家详细讲解,有这方面需求的人可以来学习下,希望你能有所收获。
德城ssl适用于网站、小程序/APP、API接口等需要进行数据传输应用场景,ssl证书未来市场广阔!成为成都创新互联公司的ssl证书销售渠道,可以享受市场价格4-6折优惠!如果有意向欢迎电话联系或者加微信:18980820575(备注:SSL证书合作)期待与您的合作!具体如下:
total = $_total ? $_total :1 ; //总条数 $this->pagesize = $_pagesize; //每页显示多少条 $this->page = $page; //当前页码 $this->pagenum = ceil($this->total / $this->pagesize); //总页码 $this->limit = "limit ".($this->page-1)*$this->pagesize.",".$this->pagesize; //分页语句 $this->url = $this->setUrl(); //地址 } //分页语句 public function limit(){ return $this->limit; } //当前的url地址 public function setUrl(){ $server = $_SERVER['REQUEST_URI']; $im = explode('/',$server); if(empty($_SERVER['PATH_INFO'])){ $array = array_splice($im,2,0,array('2'=>'index.php')); } $controller = $im[3]; $action = $im[4]; if(empty($_SERVER['PATH_INFO'])){ $servers = "http://".$_SERVER['HTTP_HOST']."/".$im[1]."/".$controller."/".$action."/"; }else{ $servers = "http://".$_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME']."/".$controller."/".$action."/"; } return $servers; //return $im; } //首页 public function first(){ //return $this->page; if($this->page > 1){ return "url."page/1'>首页"; } } //上一页 public function prev(){ if($this->page==1){ $page = 1; }else{ $page = $this->page-1; } if($this->page > 1){ return "url."page/".$page."'>上一页"; }else{ return "上一页"; } } //下一页 public function next(){ $page = $this->page+1; if($this->page < $this->pagenum){ if(empty($this->page)){ $pages = $this->page+2; return "url."page/".$pages."'>下一页"; }else{ return "url."page/".$page."'>下一页"; } }else{ return "下一页"; } } //尾页 public function last(){ if($this->page < $this->pagenum){ return "url."page/".$this->pagenum."'>尾页"; } } //分页 public function showpage(){ $page_ = ""; $page_ .= $this->first(); $page_ .= " ".$this->prev(); $page_ .= " ".$this->next(); $page_ .= " ".$this->last(); return $page_; } }
看完上述内容是否对您有帮助呢?如果还想对相关知识有进一步的了解或阅读更多相关文章,请关注创新互联行业资讯频道,感谢您对创新互联网站建设公司,的支持。
网站栏目:PHP封装分页类-创新互联
本文地址:http://myzitong.com/article/cchcee.html