Pear::Pager分页类简介

时间:2010-01-11 08:16:21   来源:第二电脑网  作者:第二电脑网

  第二电脑网导读:用性之强.下面用代码来看看它的使用范例:例子1PLAIN TEXTPHP:<?phprequire_once'Pager/Pager.php';
  正文:

Pear的Pager分页类是一个很好用的PHP分页类,扩展性很强,能够适应各种分页情况的需求,至少我在几年间大大小小的项目里,基础上没有为分页额外写过代码,全部都是用的Pager,足见Pager的可用性之强.下面用代码来看看它的使用范例:

例子1

PLAIN TEXTPHP:
  1. <?php
  2. require_once'Pager/Pager.php';
  3. $params=array(
  4.    'mode'       =>'Jumping',
  5.    'perPage'    =>3,
  6.    'delta'      =>2,
  7.    'itemData'   =>array('a','b','c','d','e',[...omissis...],'z')
  8. );
  9. $pager= & Pager::factory($params);
  10. $data  =$pager->getPageData();
  11. $links=$pager->getLinks();
  12. //$links is an ordered+associative array with 'back'/'pages'/'next'/'first'/'last'/'all' links
  13. //NB: $links['all'] is the same as $pager->links;
  14.  
  15. //echo links to other pages:
  16. echo$links['all'];
  17.  
  18. //Pager can also generate <link rel="first|prev|next|last"> tags
  19. echo$pager->linkTags;
  20.  
  21. //Show data for current page:
  22. echo'PAGED DATA: ';print_r($data);
  23.  
  24. //Results from methods:
  25. echo'getCurrentPageID()...: ';var_dump($pager->getCurrentPageID());
  26. echo'getNextPageID()......: ';var_dump($pager->getNextPageID());
  27. echo'getPreviousPageID()..: ';var_dump($pager->getPreviousPageID());
    来源:http://www.002pc.com/master/College/Programming/PHP/11730.html

收藏到:

关于《Pear::Pager分页类简介》文章的评论

共有 0 位网友发表了评论 此处只显示部分留言 点击查看完整评论页面

随机文章

    SQL Error: select * from ***_ecms_article where classid='86' and checked=1 order by rand() limit 10

顶出来的热门

    SQL Error: select * from ***_ecms_article where classid='86' and checked=1 order by diggtop desc,id desc limit 10
站内搜索: 高级搜索

热门搜索: Windows style 系统 tr IP QQ CPU 安装 function 注册 if td