Home >Backend Development >PHP Tutorial >Super paging class 20 is released, supports custom styles, and has 4 default display modes.

Super paging class 20 is released, supports custom styles, and has 4 default display modes.

WBOY
WBOYOriginal
2016-07-29 08:35:561018browse

The super powerful paging class 2.0 is released, supports custom styles, and has 4 default display modes.
I saw someone on the forum asking for Baidu paging class, so I posted the paging class from a few weeks ago.
2.0 has been revised relative to 1.0 as follows:
1. Supports PHP4 and PHP5
2. Added the function of ajax paging
3. Optimized the overall structure of the program
4. Added the function of custom style
The code is as follows:

Copy the code The code is as follows:

/**
* filename: ext_page.class.php
* @package:phpbean
* @author :feifengxlq<[url=http://www.phpobject.net/]http://www. phpobject.net/[/url]>
* @copyright :Copyright 2006 feifengxlq
* @license:version 2.0
* @create:2006-5-31
* @modify:2006-6-1
* @modify: feifengxlq 2006-11-4
* description: Super powerful paging class, four paging modes, the default paging style is similar to Baidu and Google.
* 2.0 added features: supports custom styles, custom styles, supports both PHP4 and PHP5,
* to see detail,please visit [url=http://www.phpobject.net/blog/read.php]http: //www.phpobject.net/blog/read.php[/url]?
* example:
* Mode four paging modes:
require_once('../libs/classes/page.class.php');
$page=new page(array('total'=>1000,'perpage'=>20));
echo 'mode:1
'.$page->show();
echo '< ;hr>mode:2
'.$page->show(2);
echo '


mode:3
'.$page->show(3);
echo '< ;hr>mode:4
'.$page->show(4);
Turn on AJAX:
$ajaxpage=new page(array('total'=>1000,'perpage'=>20, 'ajax'=>'ajax_page','page_name'=>'test'));
echo 'mode:1
'.$ajaxpage->show();
Adopt inherited custom paging display mode :
demo:http://www.phpobject.net/blog
*/
class page
{
/** 
  * config ,public 
  */
var $page_name="PB_page";//page tag, used to control the url page. For example, PB_page in xxx.php?PB_page=2
var $next_page='>';//Next page
var $pre_page='<';//Previous page
var $first_page='First' ;//Homepage
var $last_page='Last';//Last page
var $pre_bar='<<';//Previous paging bar
var $next_bar='>>';//Next A paging bar
var $format_left='[';
var $format_right=']';
var $is_ajax=false;//Whether AJAX paging mode is supported
/** 
  * private 
  * 
  */
var $pagebarnum=10 ;//Control the number of record strips. 
 var $totalpage=0;//总页数 
 var $ajax_acti||$last=='&'){ 
         $this->url.=$this->page_name."="; 
     }else{ 
         $this->url.='&'.$this->page_name."="; 
     } 
    }else{ 
        // 
     $this->url=$_SERVER['REQUEST_URI'].'&'.$this->page_name.'='; 
    }//end if     
   }//end if 
  }//end if 
 } 
 /**
* Set the current page
*
*/ 
 function _set_nowindex($nowindex) 
 { 
  if(empty($nowindex)){ 
   //系统获取 
   if(isset($_GET[$this->page_name])){ 
    $this->nowindex=intval($_GET[$this->page_name]); 
   } 
  }else{ 
      //手动设置 
   $this->nowindex=intval($nowindex); 
  } 
 } 
 /**
* Return the address value for the specified page
*
* @param int $pageno
* @return string $url
*/ 
 function _get_url($pageno=1) 
 { 
  return $this->url.$pageno; 
 } 
 /**
* Get pagination display text, for example, by default _get_text('1') will return [1]
*
* @param String $str
* @return string $url
*/  
 function _get_text($str) 
 { 
  return $this->format_left.$str.$this->format_right; 
 } 
 /**
* Get link address
*/ 
 function _get_link($url,$text,$style=''){ 
  $style=(empty($style))?'':'class="'.$style.'"'; 
  if($this->is_ajax){ 
      //如果是使用AJAX模式 
   return 'ajax_action_name.'(''.$url.'')">'.$text.''; 
  }else{ 
   return ''.$text.''; 
  } 
 } 
 /**
* Error handling method
*/ 
 function error($function,$errormsg) 
 { 
     die('Error in file '.__FILE__.' ,Function '.$function.'() :'.$errormsg); 
 } 

?>


提供一个简单的演示demo

复制代码 代码如下:

require_once('../libs/classes/page.class.php'); 
$page=new page(array('total'=>1000,'perpage'=>20)); 
echo 'mode:1
'.$page->show(); 
echo '


mode:2
'.$page->show(2); 
echo '
mode:3
'.$page->show(3); 
echo '
mode:4
'.$page->show(4); 
echo '
开始AJAX模式:'; 
$ajaxpage=new page(array('total'=>1000,'perpage'=>20,'ajax'=>'ajax_page','page_name'=>'test')); 
echo 'mode:1
'.$ajaxpage->show(); 
?> 


演示地址:http://traffic02.100steps.net/52site/test/page.php 
 

以上就介绍了 超强分页类20发布,支持自定义风格,默认4种显示模式,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn