lib/Pager.php
private function parseArgs() 
    {
        $pregArgSeparator = $this->argSeparator == '&' ? '' : preg_quote($this->argSeparator, '/');
        $pregValSeparator = $this->valSeparator == '=' ? '' : preg_quote($this->valSeparator, '/');
        
        if ($this->argSeparator == '&' && $this->valSeparator == '=') {
            // 常规链接应该有参数前应该有 ?
            $this->uri = str_replace('&amp;', '&', $this->uri);
            if (false === stripos($this->uri, '?')) {
                $this->uri .= '?';
            }
        } elseif (false !== stripos($this->uri, '?')) {
            // URL变量不使用&xx=yy的格式，URL中有?
            $this->uriQuery = substr($this->uri, strpos($this->uri, '?'));
            $this->uri = substr($this->uri, 0, strpos($this->uri, '?'));
        }
        
        $this->uri = rtrim($this->uri, $this->argSeparator);
        
        // POST请求参数合并入URL
        if ($_POST) {
            $argStr = http_build_query($_POST, '__', $this->argSeparator);
            
            // 键值分隔符号不是=
            if ($this->valSeparator != '=') {
                $argStr = str_replace('=', $this->valSeparator, $argStr);
            }
            
            $this->uri .= $this->argSeparator . $argStr;
        }
        
        // 从请求参数中提取当前页码
        if(preg_match_all("/[\\?&{$pregArgSeparator}]{$this->pageVar}[={$pregValSeparator}](\\d+)/i", $this->uri, $pageMatch)) {
            // 匹配?page=N、&page=N、{$this->argSeparator}page{$this->valSeparator}=N
            $this->page = end($pageMatch[1]);
        }
        $this->page <= 0 && $this->page = 1;
        
        // 允许地址栏传入每页记录数参数，则从请求参数中提取每页行数
        if ($this->allowCustomRows) {
            if(preg_match_all("/[\\?&{$pregArgSeparator}]{$this->rowsVar}[={$pregValSeparator}](\\d+)/i", $this->uri, $rowsMatch)) {
                // 匹配?page=N、&page=N、{$this->argSeparator}page{$this->valSeparator}=N
                $this->rows = end($rowsMatch[1]);
            }
            
            // 最多记录数限制
            $this->rows > $this->rowsMax && $this->rows = $this->rowsMax;
        }
        
        // 去掉URI中的分页、每页行数参数
        $this->uri = preg_replace("/([&{$pregArgSeparator}]({$this->pageVar}|{$this->rowsVar})[={$pregValSeparator}]\\d+)/", '', $this->uri);
        $this->uri = preg_replace("/(\\?({$this->pageVar}|{$this->rowsVar})[={$pregValSeparator}]\\d+)/", '?', $this->uri); // 页码、页记录数变量连在?之后，即?page=xx或?page:xxx
                    
        
        /* 页码计算 */
        
        // 最后页，也是总页数
        $this->lastPage = ceil($this->totals / $this->rows);
        
        // 当前页，page值超过最大值时取最大值做page值
        $this->page = min($this->lastPage, $this->page);
        
        // 上一页
        $this->prePage = max($this->page - 1, 1);
        
        // 下一页
        $this->nextPage = min($this->lastPage, $this->page + 1);
        
        // 起始记录，当前页在数据库查询符合结果中的起始记录
        $this->offset = max(($this->page - 1) * $this->rows, 0);    
        
        $this->isParsed = true;
    }
private function parseArgs() 
    {
        $pregArgSeparator = $this->argSeparator == '&' ? '' : preg_quote($this->argSeparator, '/');
        $pregValSeparator = $this->valSeparator == '=' ? '' : preg_quote($this->valSeparator, '/');
        
        if ($this->argSeparator == '&' && $this->valSeparator == '=') {
            // 常规链接应该有参数前应该有 ?
            $this->uri = str_replace('&amp;', '&', $this->uri);
            if (false === stripos($this->uri, '?')) {
                $this->uri .= '?';
            }
        } elseif (false !== stripos($this->uri, '?')) {
            // URL变量不使用&xx=yy的格式，URL中有?
            $this->uriQuery = substr($this->uri, strpos($this->uri, '?'));
            $this->uri = substr($this->uri, 0, strpos($this->uri, '?'));
        }
        
        $this->uri = rtrim($this->uri, $this->argSeparator);
        
        // POST请求参数合并入URL
        if ($_POST) {
            $argStr = http_build_query($_POST, '__', $this->argSeparator);
            
            // 键值分隔符号不是=
            if ($this->valSeparator != '=') {
                $argStr = str_replace('=', $this->valSeparator, $argStr);
            }
            
            $this->uri .= $this->argSeparator . $argStr;
        }
        
        // 从请求参数中提取当前页码
        if(preg_match_all("/[\\?&{$pregArgSeparator}]{$this->pageVar}[={$pregValSeparator}](\\d+)/i", $this->uri, $pageMatch)) {
            // 匹配?page=N、&page=N、{$this->argSeparator}page{$this->valSeparator}=N
            $this->page = end($pageMatch[1]);
        }
        $this->page <= 0 && $this->page = 1;
        
        // 允许地址栏传入每页记录数参数，则从请求参数中提取每页行数
        if ($this->allowCustomRows) {
            if(preg_match_all("/[\\?&{$pregArgSeparator}]{$this->rowsVar}[={$pregValSeparator}](\\d+)/i", $this->uri, $rowsMatch)) {
                // 匹配?page=N、&page=N、{$this->argSeparator}page{$this->valSeparator}=N
                $this->rows = end($rowsMatch[1]);
            }
            
            // 最多记录数限制
            $this->rows > $this->rowsMax && $this->rows = $this->rowsMax;
        }
        
        // 去掉URI中的分页、每页行数参数
        $this->uri = preg_replace("/([&{$pregArgSeparator}]({$this->pageVar}|{$this->rowsVar})[={$pregValSeparator}]\\d+)/", '', $this->uri);
        $this->uri = preg_replace("/(\\?({$this->pageVar}|{$this->rowsVar})[={$pregValSeparator}]\\d+)/", '?', $this->uri); // 页码、页记录数变量连在?之后，即?page=xx或?page:xxx
                    
        
        /* 页码计算 */
        
        // 最后页，也是总页数
        $this->lastPage = ceil($this->totals / $this->rows);
        
        // 当前页，page值超过最大值时取最大值做page值
        $this->page = min($this->lastPage, $this->page);
        
        // 上一页
        $this->prePage = max($this->page - 1, 1);
        
        // 下一页
        $this->nextPage = min($this->lastPage, $this->page + 1);
        
        // 起始记录，当前页在数据库查询符合结果中的起始记录
        $this->offset = max(($this->page - 1) * $this->rows, 0);    
        
        $this->isParsed = true;
    }
提取page,rows参数