<?php
/**
*分页
*/
class page {
public $all_count;
public $all_page;
public $page_size;
public $now_page;
public $page_link;
public function init($count)
{
$this->page_size = 10;
$this->all_count = $count;
$this->all_page = floor(($this->all_count-1)/$this->page_size)+1;
//参数
$url = $_SERVER['QUERY_STRING'];
$flag = strpos($url,'&');
$url = (0<$flag) ? substr($url,0,$flag) : $url;
//分页链接
$this->page_link = '共'.$this->all_page.'页';
$this->page_link .= ' ';
$this->page_link .= "<a href='?$url&n=0'>首页</a>";
$this->page_link .= ' ';
if(0<$this->now_page)
{
$this->page_link .= "<a href='?$url&n=".($this->now_page-1)."'>《上一页</a>";
}
else
{
$this->page_link .= '《上一页';
}
$this->page_link .= ' ';
if($this->all_page>$this->now_page)
{
$this->page_link .= "<a href='?$url&n=".($this->now_page+1)."'>下一页》</a>";
}
else
{
$this->page_link .= '下一页》';
}
$this->page_link .= ' ';
$this->page_link .= "<a href='?$url&n=".$this->all_page."'>最后一页</a>";
}
}
?>
- 上一篇:ucenter SSO 会员同步登录
- 下一篇:php 发展的未来