[PHP实例] PHP分页类
2016-04-12 16:54
531 查看
<?php
/**
* 分页类
*
* author lynnluo
* addtime 2011-08-15
*/
http://m.hwjbyby.com/nxby/qtby/262.html
define( 'PAGE_NAME','page' );// url '....php?page=2'中的page名称
define( 'CR',"\n" );// 换行符
class page
{
private $prev_label = ' 上一页 ';//
private $next_label = ' 下一页 ';//
private $first_label = ' 首页 ';//
private $last_label = ' 尾页 ';//
private $per_page = 10;//每页显示多少条
private $adjacent_num = 2;//当前页相邻的显示量
private $page_num; //总页数
private $page; //第几页
private $html;//返回分页的html源码
private $display_str_flag = true;//首页和尾页用字符串or数字显示 true:字符串 其它则显示数字
/**
* 构造函数
* $per_page int 每页显示多少条
* $totle int 总数量
*/
public function __construct( $per_page, $totle )
{http://m.hwjbyby.com/nxby/dnlc/263.html
$this->per_page = intval($per_page)<1 ? $this->per_page : intval($per_page);//每页显示条数小于1时 默认为10
$this->page_num = ceil( $totle / $this->per_page );
$this->page = isset($_GET[PAGE_NAME]) ? ( (intval($_GET[PAGE_NAME])>0) ? intval($_GET[PAGE_NAME]):1) : 1;//当前页码小于1时默认为第一页
$this->page = $this->page > $this->page_num ? $this->page_num : $this->page;//当前页码超过最大页码时默认为最后一页
$this->html = '';
}
/**
* 私有属性赋值时的错误处理
*/
public function __set( $aa ,$bb){}
/**
* 配置类的私有属性
* $ary array 键值对,键为该类的私有属性
*/
public function set( $ary = array( 'display_str_flag'=>false,
'prev_label'=>'>>',
'next_label'=>'>>',
'first_label'=>'>>',
'last_label'=>'>>',
'adjacent_num'=>5))
{
foreach( $ary as $key=>$value )
{
$this->{$key} = $value;
}
}
http://m.hwjbyby.com/nxby/dnlc/264.html
/**
* 返回当前URL
*/
private function getURL()
{
$url = $_SERVER["REQUEST_URI"].(strpos($_SERVER["REQUEST_URI"],'?')?'':"?");
$parse=parse_url($url);
if(isset($parse['query']))
{
parse_str($parse['query'],$params);
unset($params[PAGE_NAME]);
$url = $parse['path'].'?'.http_build_query($params);
}
$url .= strpos($url, '?') ? (strpos($url, '=')?'&':'') : '' ;
return $url;
}
/**
* 首页
*/
private function first_page()
{
if( $this->page == 1 )
{
$this->html .= '<span>' . $this->first_label . '</span>'.CR;
}
else
{
$this->html .= '<a href="' . $this->getURL() .PAGE_NAME.'=1">' . $this->first_label . '</a>'.CR;
}
}
/**
* 尾页
*/
private function last_page()
{
if( $this->page == $this->page_num )
{
$this->html .= '<span>' . $this->last_label . '</span>'.CR;
}
else
{
$this->html .= '<a href="' . $this->getURL() .PAGE_NAME.'='.$this->page_num.'">' . $this->last_label . '</a>'.CR;
}
}http://m.hwjbyby.com/nxby/lcxby/265.html
/**
* 上一页
*/
private function prev_page()
{
if( $this->page == 1 )
{
$this->html .= '<span>' . $this->prev_label . '</span>'.CR;
}
else
{
$this->html .= '<a href="' . $this->getURL() .PAGE_NAME.'=' . ( $this->page - 1 ) . '">' . $this->prev_label . '</a>'.CR;
}
}
/**
* 下一页
*/
private function next_page()
{
if( $this->page < $this->page_num)
{
$this->html .= '<a href="' . $this->getURL().PAGE_NAME.'=' . ( $this->page+1) . '">' . $this->next_label . '</a>'.CR;
}
else
{
$this->html .= '<span>' . $this->next_label . '</span>'.CR;
}
}
/**
* 第一块 第一个省略号前的那块
*/
private function first_block()
{
if( $this->page > ( $this->adjacent_num+1 ) )
{
$this->html.= '<a href="' . $this->getURL().PAGE_NAME.'=1">1</a>'.CR;
}
if( $this->page > ( $this->adjacent_num+2 ) )
{
$this->html.= '...'.CR;
}
}
/**
* 第二块 两个省略号中间的那块
*/
private function middle_block()
{
$page_min = ( $this->page > $this->adjacent_num ) ? ( $this->page - $this->adjacent_num ) : 1;
$page_max = ( $this->page < ($this->page_num-$this->adjacent_num)) ? ($this->page+$this->adjacent_num) : $this->page_num ;
for( $i=$page_min; $i<=$page_max; $i++)
{
if( $i == $this->page )
{
$this->html .= '<span class="current">' . $i . '</span>'.CR;
}
else
{
$this->html .= '<a href="' . $this->getURL() .PAGE_NAME.'=' . $i . '">' . $i . '</a>'.CR;
}
}
}
/**
* 最后一块 最后一个省略号后的的那块
*/
private function last_block()
{http://m.hwjbyby.com/nxby/dnlc/266.html
if( $this->page < ($this->page_num - $this->adjacent_num - 1))
{
$this->html .= '...'.CR;
}
if( $this->page < ($this->page_num-$this->adjacent_num ))
{
$this->html .= '<a href="' . $this->getURL() .PAGE_NAME.'=' . $this->page_num . '">' . $this->page_num . '</a>'.CR;
}
}
/**
* 显示分页
*
* $out_flag bool 输出和反回分页html的标志 true:直接输出 false:返回分页的html
*
*/
public function display( $out_flag = false )
{
$this->html = '<div class="pagin">'.CR;
m.hwjbyby.com
if( $this->display_str_flag === true )
{//首页和尾页用字符串显示
$this->first_page(); //显示首页
$this->prev_page(); //显示上一页
$this->middle_block(); //显示中间块
$this->next_page(); //显示下一页
$this->last_page(); //显示最后一页
}
else
{//首页和尾页用数字显示
$this->prev_page(); //显示上一页
$this->first_block(); //显示第一块
$this->middle_block(); //显示中间块
$this->last_block(); //显示最后一块
$this->next_page(); //显示下一页
}
$this->html .= '</div>';
if($out_flag === false)
{//返回分页 html码
return $this->html;
}
else
{//输出分页 html码
echo $html;
}
}
}
/*************demo **************/
$page = new page(3,55);
$page->set( $ary = array( 'display_str_flag'=>false,
'prev_label'=>'上',
'next_label'=>'下一页',
'last_label'=>'末',));
echo $page->display();
/*************demo **************/
?>
分页类 ~ 6KB 下载(39)
?<?php
/**
* 分页类
*
* author lynnluo
* addtime 2011-08-15
*/
define( 'PAGE_NAME','page' );// url '....php?page=2'中的page名称
define( 'CR',"\n" );// 换行符
class page
{
private $prev_label = ' 上一页 ';//
private $next_label = ' 下一页 ';//
private $first_label = ' 首页 ';//
private $last_label = ' 尾页 ';//
private $per_page = 10;//每页显示多少条
private $adjacent_num = 2;//当前页相邻的显示量
private $page_num; //总页数
private $page; //第几页
private $html;//返回分页的html源码
private $display_str_flag = true;//首页和尾页用字符串or数字显示 true:字符串 其它则显示数字
/**
* 构造函数
* $per_page int 每页显示多少条
* $totle int 总数量
*/
public function __construct( $per_page, $totle )
{
$this->per_page = intval($per_page)<1 ? $this->per_page : intval($per_page);//每页显示条数小于1时 默认为10
$this->page_num = ceil( $totle / $this->per_page );
$this->page = isset($_GET[PAGE_NAME]) ? ( (intval($_GET[PAGE_NAME])>0) ? intval($_GET[PAGE_NAME]):1) : 1;//当前页码小于1时默认为第一页
$this->page = $this->page > $this->page_num ? $this->page_num : $this->page;//当前页码超过最大页码时默认为最后一页
$this->html = '';
}
/**
* 私有属性赋值时的错误处理
*/
public function __set( $aa ,$bb){}
/**
* 配置类的私有属性
* $ary array 键值对,键为该类的私有属性
*/
public function set( $ary = array( 'display_str_flag'=>false,
'prev_label'=>'>>',
'next_label'=>'>>',
'first_label'=>'>>',
'last_label'=>'>>',
'adjacent_num'=>5))
{
foreach( $ary as $key=>$value )
{
$this->{$key} = $value;
}
}
/**
* 返回当前URL
*/
private function getURL()
{
$url = $_SERVER["REQUEST_URI"].(strpos($_SERVER["REQUEST_URI"],'?')?'':"?");
$parse=parse_url($url);
if(isset($parse['query']))
{
parse_str($parse['query'],$params);
unset($params[PAGE_NAME]);
$url = $parse['path'].'?'.http_build_query($params);
}
$url .= strpos($url, '?') ? (strpos($url, '=')?'&':'') : '' ;
return $url;
}
/**
* 首页
*/
private function first_page()
{
if( $this->page == 1 )
{
$this->html .= '<span>' . $this->first_label . '</span>'.CR;
}
else
{
$this->html .= '<a href="' . $this->getURL() .PAGE_NAME.'=1">' . $this->first_label . '</a>'.CR;
}
}
/**
* 尾页
*/
private function last_page()
{
if( $this->page == $this->page_num )
{
$this->html .= '<span>' . $this->last_label . '</span>'.CR;
}
else
{
$this->html .= '<a href="' . $this->getURL() .PAGE_NAME.'='.$this->page_num.'">' . $this->last_label . '</a>'.CR;
}
}
/**
* 上一页
*/
private function prev_page()
{
if( $this->page == 1 )
{
$this->html .= '<span>' . $this->prev_label . '</span>'.CR;
}
else
{
$this->html .= '<a href="' . $this->getURL() .PAGE_NAME.'=' . ( $this->page - 1 ) . '">' . $this->prev_label . '</a>'.CR;
}
}
/**
* 下一页
*/
private function next_page()
{
if( $this->page < $this->page_num)
{
$this->html .= '<a href="' . $this->getURL().PAGE_NAME.'=' . ( $this->page+1) . '">' . $this->next_label . '</a>'.CR;
}
else
{
$this->html .= '<span>' . $this->next_label . '</span>'.CR;
}
}
/**
* 第一块 第一个省略号前的那块
*/
private function first_block()
{
if( $this->page > ( $this->adjacent_num+1 ) )
{
$this->html.= '<a href="' . $this->getURL().PAGE_NAME.'=1">1</a>'.CR;
}
if( $this->page > ( $this->adjacent_num+2 ) )
{
$this->html.= '...'.CR;
}
}
/**
* 第二块 两个省略号中间的那块
*/
private function middle_block()
{
$page_min = ( $this->page > $this->adjacent_num ) ? ( $this->page - $this->adjacent_num ) : 1;
$page_max = ( $this->page < ($this->page_num-$this->adjacent_num)) ? ($this->page+$this->adjacent_num) : $this->page_num ;
for( $i=$page_min; $i<=$page_max; $i++)
{
if( $i == $this->page )
{
$this->html .= '<span class="current">' . $i . '</span>'.CR;
}
else
{
$this->html .= '<a href="' . $this->getURL() .PAGE_NAME.'=' . $i . '">' . $i . '</a>'.CR;
}
}
}
/**
* 最后一块 最后一个省略号后的的那块
*/
private function last_block()
{
if( $this->page < ($this->page_num - $this->adjacent_num - 1))
{
$this->html .= '...'.CR;
}
if( $this->page < ($this->page_num-$this->adjacent_num ))
{
$this->html .= '<a href="' . $this->getURL() .PAGE_NAME.'=' . $this->page_num . '">' . $this->page_num . '</a>'.CR;
}
}
/**
* 显示分页
*
* $out_flag bool 输出和反回分页html的标志 true:直接输出 false:返回分页的html
*
*/
public function display( $out_flag = false )
{
$this->html = '<div class="pagin">'.CR;
if( $this->display_str_flag === true )
{//首页和尾页用字符串显示
$this->first_page(); //显示首页
$this->prev_page(); //显示上一页
$this->middle_block(); //显示中间块
$this->next_page(); //显示下一页
$this->last_page(); //显示最后一页
}
else
{//首页和尾页用数字显示
$this->prev_page(); //显示上一页
$this->first_block(); //显示第一块
$this->middle_block(); //显示中间块
$this->last_block(); //显示最后一块
$this->next_page(); //显示下一页
}
$this->html .= '</div>';
if($out_flag === false)
{//返回分页 html码
return $this->html;
}
else
{//输出分页 html码
echo $html;
}
}
}
/*************demo **************/
$page = new page(3,55);
$page->set( $ary = array( 'display_str_flag'=>false,
'prev_label'=>'上',
'next_label'=>'下一页',
'last_label'=>'末',));
echo $page->display();
/*************demo **************/
?>
/**
* 分页类
*
* author lynnluo
* addtime 2011-08-15
*/
http://m.hwjbyby.com/nxby/qtby/262.html
define( 'PAGE_NAME','page' );// url '....php?page=2'中的page名称
define( 'CR',"\n" );// 换行符
class page
{
private $prev_label = ' 上一页 ';//
private $next_label = ' 下一页 ';//
private $first_label = ' 首页 ';//
private $last_label = ' 尾页 ';//
private $per_page = 10;//每页显示多少条
private $adjacent_num = 2;//当前页相邻的显示量
private $page_num; //总页数
private $page; //第几页
private $html;//返回分页的html源码
private $display_str_flag = true;//首页和尾页用字符串or数字显示 true:字符串 其它则显示数字
/**
* 构造函数
* $per_page int 每页显示多少条
* $totle int 总数量
*/
public function __construct( $per_page, $totle )
{http://m.hwjbyby.com/nxby/dnlc/263.html
$this->per_page = intval($per_page)<1 ? $this->per_page : intval($per_page);//每页显示条数小于1时 默认为10
$this->page_num = ceil( $totle / $this->per_page );
$this->page = isset($_GET[PAGE_NAME]) ? ( (intval($_GET[PAGE_NAME])>0) ? intval($_GET[PAGE_NAME]):1) : 1;//当前页码小于1时默认为第一页
$this->page = $this->page > $this->page_num ? $this->page_num : $this->page;//当前页码超过最大页码时默认为最后一页
$this->html = '';
}
/**
* 私有属性赋值时的错误处理
*/
public function __set( $aa ,$bb){}
/**
* 配置类的私有属性
* $ary array 键值对,键为该类的私有属性
*/
public function set( $ary = array( 'display_str_flag'=>false,
'prev_label'=>'>>',
'next_label'=>'>>',
'first_label'=>'>>',
'last_label'=>'>>',
'adjacent_num'=>5))
{
foreach( $ary as $key=>$value )
{
$this->{$key} = $value;
}
}
http://m.hwjbyby.com/nxby/dnlc/264.html
/**
* 返回当前URL
*/
private function getURL()
{
$url = $_SERVER["REQUEST_URI"].(strpos($_SERVER["REQUEST_URI"],'?')?'':"?");
$parse=parse_url($url);
if(isset($parse['query']))
{
parse_str($parse['query'],$params);
unset($params[PAGE_NAME]);
$url = $parse['path'].'?'.http_build_query($params);
}
$url .= strpos($url, '?') ? (strpos($url, '=')?'&':'') : '' ;
return $url;
}
/**
* 首页
*/
private function first_page()
{
if( $this->page == 1 )
{
$this->html .= '<span>' . $this->first_label . '</span>'.CR;
}
else
{
$this->html .= '<a href="' . $this->getURL() .PAGE_NAME.'=1">' . $this->first_label . '</a>'.CR;
}
}
/**
* 尾页
*/
private function last_page()
{
if( $this->page == $this->page_num )
{
$this->html .= '<span>' . $this->last_label . '</span>'.CR;
}
else
{
$this->html .= '<a href="' . $this->getURL() .PAGE_NAME.'='.$this->page_num.'">' . $this->last_label . '</a>'.CR;
}
}http://m.hwjbyby.com/nxby/lcxby/265.html
/**
* 上一页
*/
private function prev_page()
{
if( $this->page == 1 )
{
$this->html .= '<span>' . $this->prev_label . '</span>'.CR;
}
else
{
$this->html .= '<a href="' . $this->getURL() .PAGE_NAME.'=' . ( $this->page - 1 ) . '">' . $this->prev_label . '</a>'.CR;
}
}
/**
* 下一页
*/
private function next_page()
{
if( $this->page < $this->page_num)
{
$this->html .= '<a href="' . $this->getURL().PAGE_NAME.'=' . ( $this->page+1) . '">' . $this->next_label . '</a>'.CR;
}
else
{
$this->html .= '<span>' . $this->next_label . '</span>'.CR;
}
}
/**
* 第一块 第一个省略号前的那块
*/
private function first_block()
{
if( $this->page > ( $this->adjacent_num+1 ) )
{
$this->html.= '<a href="' . $this->getURL().PAGE_NAME.'=1">1</a>'.CR;
}
if( $this->page > ( $this->adjacent_num+2 ) )
{
$this->html.= '...'.CR;
}
}
/**
* 第二块 两个省略号中间的那块
*/
private function middle_block()
{
$page_min = ( $this->page > $this->adjacent_num ) ? ( $this->page - $this->adjacent_num ) : 1;
$page_max = ( $this->page < ($this->page_num-$this->adjacent_num)) ? ($this->page+$this->adjacent_num) : $this->page_num ;
for( $i=$page_min; $i<=$page_max; $i++)
{
if( $i == $this->page )
{
$this->html .= '<span class="current">' . $i . '</span>'.CR;
}
else
{
$this->html .= '<a href="' . $this->getURL() .PAGE_NAME.'=' . $i . '">' . $i . '</a>'.CR;
}
}
}
/**
* 最后一块 最后一个省略号后的的那块
*/
private function last_block()
{http://m.hwjbyby.com/nxby/dnlc/266.html
if( $this->page < ($this->page_num - $this->adjacent_num - 1))
{
$this->html .= '...'.CR;
}
if( $this->page < ($this->page_num-$this->adjacent_num ))
{
$this->html .= '<a href="' . $this->getURL() .PAGE_NAME.'=' . $this->page_num . '">' . $this->page_num . '</a>'.CR;
}
}
/**
* 显示分页
*
* $out_flag bool 输出和反回分页html的标志 true:直接输出 false:返回分页的html
*
*/
public function display( $out_flag = false )
{
$this->html = '<div class="pagin">'.CR;
m.hwjbyby.com
if( $this->display_str_flag === true )
{//首页和尾页用字符串显示
$this->first_page(); //显示首页
$this->prev_page(); //显示上一页
$this->middle_block(); //显示中间块
$this->next_page(); //显示下一页
$this->last_page(); //显示最后一页
}
else
{//首页和尾页用数字显示
$this->prev_page(); //显示上一页
$this->first_block(); //显示第一块
$this->middle_block(); //显示中间块
$this->last_block(); //显示最后一块
$this->next_page(); //显示下一页
}
$this->html .= '</div>';
if($out_flag === false)
{//返回分页 html码
return $this->html;
}
else
{//输出分页 html码
echo $html;
}
}
}
/*************demo **************/
$page = new page(3,55);
$page->set( $ary = array( 'display_str_flag'=>false,
'prev_label'=>'上',
'next_label'=>'下一页',
'last_label'=>'末',));
echo $page->display();
/*************demo **************/
?>
分页类 ~ 6KB 下载(39)
?<?php
/**
* 分页类
*
* author lynnluo
* addtime 2011-08-15
*/
define( 'PAGE_NAME','page' );// url '....php?page=2'中的page名称
define( 'CR',"\n" );// 换行符
class page
{
private $prev_label = ' 上一页 ';//
private $next_label = ' 下一页 ';//
private $first_label = ' 首页 ';//
private $last_label = ' 尾页 ';//
private $per_page = 10;//每页显示多少条
private $adjacent_num = 2;//当前页相邻的显示量
private $page_num; //总页数
private $page; //第几页
private $html;//返回分页的html源码
private $display_str_flag = true;//首页和尾页用字符串or数字显示 true:字符串 其它则显示数字
/**
* 构造函数
* $per_page int 每页显示多少条
* $totle int 总数量
*/
public function __construct( $per_page, $totle )
{
$this->per_page = intval($per_page)<1 ? $this->per_page : intval($per_page);//每页显示条数小于1时 默认为10
$this->page_num = ceil( $totle / $this->per_page );
$this->page = isset($_GET[PAGE_NAME]) ? ( (intval($_GET[PAGE_NAME])>0) ? intval($_GET[PAGE_NAME]):1) : 1;//当前页码小于1时默认为第一页
$this->page = $this->page > $this->page_num ? $this->page_num : $this->page;//当前页码超过最大页码时默认为最后一页
$this->html = '';
}
/**
* 私有属性赋值时的错误处理
*/
public function __set( $aa ,$bb){}
/**
* 配置类的私有属性
* $ary array 键值对,键为该类的私有属性
*/
public function set( $ary = array( 'display_str_flag'=>false,
'prev_label'=>'>>',
'next_label'=>'>>',
'first_label'=>'>>',
'last_label'=>'>>',
'adjacent_num'=>5))
{
foreach( $ary as $key=>$value )
{
$this->{$key} = $value;
}
}
/**
* 返回当前URL
*/
private function getURL()
{
$url = $_SERVER["REQUEST_URI"].(strpos($_SERVER["REQUEST_URI"],'?')?'':"?");
$parse=parse_url($url);
if(isset($parse['query']))
{
parse_str($parse['query'],$params);
unset($params[PAGE_NAME]);
$url = $parse['path'].'?'.http_build_query($params);
}
$url .= strpos($url, '?') ? (strpos($url, '=')?'&':'') : '' ;
return $url;
}
/**
* 首页
*/
private function first_page()
{
if( $this->page == 1 )
{
$this->html .= '<span>' . $this->first_label . '</span>'.CR;
}
else
{
$this->html .= '<a href="' . $this->getURL() .PAGE_NAME.'=1">' . $this->first_label . '</a>'.CR;
}
}
/**
* 尾页
*/
private function last_page()
{
if( $this->page == $this->page_num )
{
$this->html .= '<span>' . $this->last_label . '</span>'.CR;
}
else
{
$this->html .= '<a href="' . $this->getURL() .PAGE_NAME.'='.$this->page_num.'">' . $this->last_label . '</a>'.CR;
}
}
/**
* 上一页
*/
private function prev_page()
{
if( $this->page == 1 )
{
$this->html .= '<span>' . $this->prev_label . '</span>'.CR;
}
else
{
$this->html .= '<a href="' . $this->getURL() .PAGE_NAME.'=' . ( $this->page - 1 ) . '">' . $this->prev_label . '</a>'.CR;
}
}
/**
* 下一页
*/
private function next_page()
{
if( $this->page < $this->page_num)
{
$this->html .= '<a href="' . $this->getURL().PAGE_NAME.'=' . ( $this->page+1) . '">' . $this->next_label . '</a>'.CR;
}
else
{
$this->html .= '<span>' . $this->next_label . '</span>'.CR;
}
}
/**
* 第一块 第一个省略号前的那块
*/
private function first_block()
{
if( $this->page > ( $this->adjacent_num+1 ) )
{
$this->html.= '<a href="' . $this->getURL().PAGE_NAME.'=1">1</a>'.CR;
}
if( $this->page > ( $this->adjacent_num+2 ) )
{
$this->html.= '...'.CR;
}
}
/**
* 第二块 两个省略号中间的那块
*/
private function middle_block()
{
$page_min = ( $this->page > $this->adjacent_num ) ? ( $this->page - $this->adjacent_num ) : 1;
$page_max = ( $this->page < ($this->page_num-$this->adjacent_num)) ? ($this->page+$this->adjacent_num) : $this->page_num ;
for( $i=$page_min; $i<=$page_max; $i++)
{
if( $i == $this->page )
{
$this->html .= '<span class="current">' . $i . '</span>'.CR;
}
else
{
$this->html .= '<a href="' . $this->getURL() .PAGE_NAME.'=' . $i . '">' . $i . '</a>'.CR;
}
}
}
/**
* 最后一块 最后一个省略号后的的那块
*/
private function last_block()
{
if( $this->page < ($this->page_num - $this->adjacent_num - 1))
{
$this->html .= '...'.CR;
}
if( $this->page < ($this->page_num-$this->adjacent_num ))
{
$this->html .= '<a href="' . $this->getURL() .PAGE_NAME.'=' . $this->page_num . '">' . $this->page_num . '</a>'.CR;
}
}
/**
* 显示分页
*
* $out_flag bool 输出和反回分页html的标志 true:直接输出 false:返回分页的html
*
*/
public function display( $out_flag = false )
{
$this->html = '<div class="pagin">'.CR;
if( $this->display_str_flag === true )
{//首页和尾页用字符串显示
$this->first_page(); //显示首页
$this->prev_page(); //显示上一页
$this->middle_block(); //显示中间块
$this->next_page(); //显示下一页
$this->last_page(); //显示最后一页
}
else
{//首页和尾页用数字显示
$this->prev_page(); //显示上一页
$this->first_block(); //显示第一块
$this->middle_block(); //显示中间块
$this->last_block(); //显示最后一块
$this->next_page(); //显示下一页
}
$this->html .= '</div>';
if($out_flag === false)
{//返回分页 html码
return $this->html;
}
else
{//输出分页 html码
echo $html;
}
}
}
/*************demo **************/
$page = new page(3,55);
$page->set( $ary = array( 'display_str_flag'=>false,
'prev_label'=>'上',
'next_label'=>'下一页',
'last_label'=>'末',));
echo $page->display();
/*************demo **************/
?>
相关文章推荐
- [PHP实例] 使用PHPZip解压缩文件
- [PHP实例] PHP多文件上传实现
- 23、php知识点总结基础教程--part-1
- 一些PHP性能的优化
- PHP优化加速之Opcache使用总结
- php的ob缓存
- TP-link家庭无线路由安装及设置方法
- TP-Link 家庭 无线 路由器 设置 安装 如何上网
- PHP json_encode 中文乱码解决方法
- 常用FTP命令
- ContentProvider和Uri详解
- php函数 mkdir() 用法小结
- Yii2的主从数据库设置
- PHP函数的实现原理及性能分析[2010年前文章]
- thinkphp输出表格
- php交互篇(二)session 与 cookie
- PHP调试利器XDebug的安装与使用
- 10种处理PHP字符串的措施
- php生成二维码
- Thinkphp ~runtime.php