php 分页类 兄弟连的分页类无法获取到url的参数和值。
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php 分页类 兄弟连的分页类无法获取到url的参数和值。相关的知识,希望对你有一定的参考价值。
在本地测试可以正常使用,但传到服务器就无法获取url的参数和值,服务器php版本是:5.2.8
<?php
class Page
private $total;
private $listRows;
private $limit;
private $uri;
private $pageNum; //页数
private $config=array('header'=>"个", "prev"=>"上一页", "next"=>"下一页", "first"=>"首 页", "last"=>"尾 页");
private $listNum=8;
/*
* $total
* $listRows
*/
public function __construct($total, $listRows=10, $pa="")
$this->total=$total;
$this->listRows=$listRows;
$this->uri=$this->getUri($pa);
$this->page=!empty($_GET["page"]) ? $_GET["page"] : 1;
$this->pageNum=ceil($this->total/$this->listRows);
$this->limit=$this->setLimit();
private function setLimit()
return "Limit ".($this->page-1)*$this->listRows.", $this->listRows";
private function getUri($pa)
$url=$_SERVER["REQUEST_URI"].(strpos($_SERVER["REQUEST_URI"], '?')?'':"?").$pa;
$parse=parse_url($url);
if(isset($parse["query"]))
parse_str($parse['query'],$params);
unset($params["page"]);
$url=$parse['path'].'?'.http_build_query($params);
return $url;
private function __get($args)
if($args=="limit")
return $this->limit;
else
return null;
<? php var_dump($_SERVER["REQUEST_URI"]); ?>追问
检查为 空
追答那你就先在getUri的方法里加上判断。
private function getUri($pa)
//如果$_SERVER['REQUEST_URI']内容为空 则运行
if ( empty( $_SERVER['REQUEST_URI'] ) )
//判定是否是IIS7 并且赋值$_SERVER['REQUEST_URI']
if (isset($_SERVER['HTTP_X_ORIGINAL_URL']))
$_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_ORIGINAL_URL'];
//如果不是IIS7 判定是否是IIS6 并且赋值$_SERVER['REQUEST_URI']
else if (isset($_SERVER['HTTP_X_REWRITE_URL']))
$_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_REWRITE_URL'];
else
// 使用ORIG_PATH_INFO如果没有就使用PATH_INFO
if ( !isset($_SERVER['PATH_INFO']) && isset($_SERVER['ORIG_PATH_INFO']) )
$_SERVER['PATH_INFO'] = $_SERVER['ORIG_PATH_INFO'];
// Some IIS + PHP configurations puts the script-name in the path-info (No need to append it twice)
if ( isset($_SERVER['PATH_INFO']) )
if ( $_SERVER['PATH_INFO'] == $_SERVER['SCRIPT_NAME'] )
$_SERVER['REQUEST_URI'] = $_SERVER['PATH_INFO'];
else
$_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] . $_SERVER['PATH_INFO'];
$url=$_SERVER["REQUEST_URI"].(strpos($_SERVER["REQUEST_URI"], '?')?'':"?").$pa;
$parse=parse_url($url);
if(isset($parse["query"]))
parse_str($parse['query'],$params);
unset($params["page"]);
$url=$parse['path'].'?'.http_build_query($params);
return $url;
还是不行啊,兄弟!
参考技术A 到兄弟连论坛发帖问下,让高胖回答以上是关于php 分页类 兄弟连的分页类无法获取到url的参数和值。的主要内容,如果未能解决你的问题,请参考以下文章