点下页和尾页出现404页面,是这代码哪有问题吗?
<?php
class PageMydecms
{
public $mydeCmsCount; //总记录数
private $mydeCmsSize; //每页记录数
private $mydeCmsPage; //当前页
public $mydeCmsPageCount; //总页数
private $mydeCmsPageUrl; //页面url
private $mydeCmsPageStartUrl; //起始页
private $mydeCmsPageStopUrl; //结束页
private $mydeCmsIndexPageUrl; //首页(特殊用途,比如可以写目录)
/**
* 构造函数
* @param $mydeCmsCount => 记录数
* @param $mydeCmsSize => 每页显示记录数
* @param $mydeCmsPage => 当前页码
* @param $mydeCmsPageUrl => 分页URL
* @param $mydeCmsIndexPageUrl => 默认首页
* @return string
**/
function __construct($mydeCmsCount=0, $mydeCmsSize=10,$mydeCmsPage=1,$mydeCmsPageUrl,$mydeCmsIndexPageUrl="")
{
$this -> mydeCmsCount = $this -> glstr($mydeCmsCount);
$this -> mydeCmsSize = $this -> glstr($mydeCmsSize);
$this -> mydeCmsPage = $this -> glstr($mydeCmsPage);
$this -> mydeCmsIndexPageUrl = $mydeCmsIndexPageUrl;
$this -> mydeCmsPageLimit = ($this -> mydeCmsPage * $this -> mydeCmsSize) - $this -> mydeCmsSize;
$this -> mydeCmsPageUrl = $mydeCmsPageUrl;
if($this -> mydeCmsPage < 1) $this -> mydeCmsPage =1;
if($this -> mydeCmsCount < 0) $this -> mydeCmsPage =0;
$this -> mydeCmsPageCount = ceil($this -> mydeCmsCount/$this -> mydeCmsSize);
if($this -> mydeCmsPageCount < 1) $this -> mydeCmsPageCount = 1;
if($this -> mydeCmsPage > $this -> mydeCmsPageCount) $this -> mydeCmsPage = $this -> mydeCmsPageCount;
$this -> mydeCmsPageStartUrl = $this -> mydeCmsPage - 2;
$this -> mydeCmsPageStopUrl = $this -> mydeCmsPage + 2;
if($this -> mydeCmsPageStartUrl < 1){
$this -> mydeCmsPageStopUrl = $this -> mydeCmsPageStopUrl + (1 - $this -> mydeCmsPageStartUrl);
$this -> mydeCmsPageStartUrl = 1;
}
if($this -> mydeCmsPageStopUrl > $this -> mydeCmsPageCount){
$this -> mydeCmsPageStartUrl = $this -> mydeCmsPageStartUrl - ($this -> mydeCmsPageStopUrl - $this -> mydeCmsPageCount);
$this -> mydeCmsPageStopUrl = $this -> mydeCmsPageCount;
if($this -> mydeCmsPageStartUrl < 1) $this -> mydeCmsPageStartUrl = 1;
}
}
/**
* 返回首页代码函数
* @return string
**/
private function mydeCmsPageHome()
{
if($this -> mydeCmsPage != 1){
return " <li class=\"page_a\"><a rel=\"nofollow\" href=\"".($this -> mydeCmsIndexPageUrl <>"" ? $this -> mydeCmsIndexPageUrl : $this -> mydeCmsPageReplace(1))."\" title=\"首页\" >首页</a></li>\n";
}else{
return " <li>首页</li>\n";
}
}
/**
* 返回上一页代码函数
* @return string
**/
private function mydeCmsPagePrev()
{
if($this -> mydeCmsPage != 1){
return " <li class=\"page_a\"><a rel=\"nofollow\" href=\"".(($this -> mydeCmsIndexPageUrl <>"" && $this->mydeCmsPage-1 ==1) ? $this -> mydeCmsIndexPageUrl : $this -> mydeCmsPageReplace($this->mydeCmsPage-1)) ."\" title=\"上一页\" >上一页</a></li>\n";
}else{
return " <li>上一页</li>\n";
}
}
/**
* 返回下一页代码函数
* @return string
**/
private function mydeCmsPageNext()
{
if($this -> mydeCmsPage != $this -> mydeCmsPageCount){
return " <li class=\"page_a\"><a rel=\"nofollow\" href=\"".$this -> mydeCmsPageReplace($this->mydeCmsPage+1) ."\" title=\"下一页\" >下一页</a></li>\n";
}else{
return " <li>下一页</li>\n";
}
}
/**
* 返回尾页代码函数
* @return string
**/
private function mydeCmsPageLast() //尾页
{
if($this -> mydeCmsPage != $this -> mydeCmsPageCount){
return " <li class=\"page_a\"><a rel=\"nofollow\" href=\"".$this -> mydeCmsPageReplace($this -> mydeCmsPageCount)."\" title=\"尾页\" >尾页</a></li>\n";
}else{
return " <li>尾页</li>\n";
}
}
/**
* 输出显示分页函数
* @param $pageDivId => 分页代码中div的ID
* @param $isPC => 显示类型(true为电脑端,否则为手机端)
* @param $goto => 是否提供输入框页码快速跳转(true允许,否则为不允许)
* @return string
**/
public function mydeCmsShow($pageDivId='page',$isPC=true,$goto=true) {
$str = "<div id=\"".$pageDivId."\" class=\"pages\">\n <ul>\n ";
$str .= " <li>总记录:<span>".$this -> mydeCmsCount."</span></li>\n";
$str .= " <li><span>".$this -> mydeCmsPage."</span>/<span>".$this -> mydeCmsPageCount."</span></li>\n";
$str .= $this -> mydeCmsPageHome();
$str .= $this -> mydeCmsPagePrev();
if($isPC){
for($page_for_i = $this -> mydeCmsPageStartUrl;$page_for_i <= $this -> mydeCmsPageStopUrl; $page_for_i++){
if($this -> mydeCmsPage == $page_for_i){
$str .= " <li class=\"on\">".$page_for_i."</li>\n";
}else{
if($page_for_i==1 && $this -> mydeCmsIndexPageUrl <>""){
$str .= " <li class=\"page_a\"><a href=\"".$this -> mydeCmsIndexPageUrl."\" title=\"第".$page_for_i."页\">";
$str .= $page_for_i . "</a></li>\n";
}else{
$str .= " <li class=\"page_a\"><a href=\"".$this -> mydeCmsPageReplace($page_for_i)."\" title=\"第".$page_for_i."页\">";
$str .= $page_for_i . "</a></li>\n";
}
}
}
}else{
$str .= " <li class=\"on\">".$this -> mydeCmsPage."</li>\n";
}
$str .= $this -> mydeCmsPageNext();
$str .= $this -> mydeCmsPageLast();
if($goto){
$str .= " <li class=\"pages_input\"><input type=\"text\" value=\"".$this -> mydeCmsPage."\"";
$str .= " οnkeydοwn=\"javascript: if(event.keyCode==13){ location='";
$str .= $this -> mydeCmsPageReplace("'+this.value+'")."';return false;}\"";
$str .= " title=\"输入您想要到达的页码\" /></li>\n";
}
$str .= " </ul>\n <div class=\"page_clear\"></div>\n</div>";
return $str;
}
/**
* 将非数字字符过滤掉
* @param $idstr => 要过滤的原字符串
* @return string
**/
private function glstr($idstr){
return preg_replace("/[^0-9]/u","",$idstr);
}
/**
* 替换分页标签
* @param $page => 页码
* @return string
**/
private function mydeCmsPageReplace($page)
{
return str_replace("{page}", $page, $this -> mydeCmsPageUrl);
}
}
/*-------------------------实例--------------------------------*
$page = new PageClass(1000,5,$_GET['page'],'?page={page}');
$page = new PageClass(1000,5,$_GET['page'],'list-{page}.html');
$page -> mydeCmsPageWrite();
*/
?>
转载于:https://my.oschina.net/u/3765673/blog/1607591
- angular2项目构建后部署到Tomcat刷新页面出现404的问题
- wordpress更改“固定链接”模式后,页面出现404原因及解决方法
- jsp 静态页面 获取完整项目路径,设置base标签,防止出现404错误
- http 如何强转为 https,几行JS 代码就搞定了,网上说得很难一样!还有如何自定义 404页面
- 防止登录页面出现在frame中js代码
- WordPress在lnmp环境下打开后台页面出现404错误
- vue 在nginx下页面刷新出现404问题解决和在nginx下页面加载了js但是页面显示空白问题解决...
- Could not find action or result 导致 页面出现404错误
- vue 在nginx下页面刷新出现404问题解决和在nginx下页面加载了js但是页面显示空白问题解决
- wordpress更改“固定链接”模式后,页面出现404原因及解决方法
- vue路由history模式刷新页面出现404问题
- 页面出现404,500,400错误{转}
- js 页面关闭前的出现提示的实现代码
- wordpress更改“固定链接”模式后,页面出现404原因及解决方法
- 网站404页面3秒后跳到首页的实例代码
- js 页面关闭前的出现提示的实现代码
- Springmvc 访问页面出现404错误
- 史上最全的CSS hack方式一览 jQuery 图片轮播的代码分离 JQuery中的动画 C#中Trim()、TrimStart()、TrimEnd()的用法 marquee 标签的使用详情 js鼠标事件 js添加遮罩层 页面上通过地址栏传值时出现乱码的两种解决方法 ref和out的区别在c#中 总结
- idea+springboot聚合项目整合jsp页面出现404问题的原因及解决措施
- 查询软件和硬件列表清单[将文章里代码另存为 list.vbs,双击运行就会出现一个html页面]