php面向对象分页类代码
maxRows = $maxRows; $this->pageSize= $pageSize; //获取当前页 $this->page = isset($_GET['p'])?$_GET['p']:1; $this->getMaxPage(); $this->checkPage(); //获取和封装url地址 $this->url = $_SERVER["PHP_SELF"]; $this->getParams(); } //获取分页信息 public function limit(){ return (($this->page-1)*$this->pageSize).",".$this->pageSize; } //计算分页中的最大页数 private function getMaxPage(){ $this->maxPage = ceil($this->maxRows/$this->pageSize); } //判断当前页数是否越界 private function checkPage(){ if($this->page>$this->maxPage){ $this->page = $this->maxPage; } if($this->page<1){ $this->page=1; } } //封装url上搜索条件 private function getParams(){ foreach($_GET as $k=>$v){ if($k!="p" && !empty($v)){ $this->params.="&{$k}={$v}"; } } } //生成分页HTML代码 public function show(){ $str = ""; $str.= "当前第{$this->page}/{$this->maxPage}页 共计{$this->maxRows}条 "; $str.= " 首页 "; $str.= " 上一页 "; $str.= " 下一页 "; $str.= " 末页 "; return $str; } }
网站题目:php面向对象分页类代码
本文链接:http://scyanting.com/article/ihpsdh.html