Pagination code of php article content. The pagination code of the php article content is operated based on the pagination characters inserted by the editor. we can split the pages with ultra-beautiful offset effects. Pagination of article content pagination php Tutorial php article content pagination code is operated based on the pagination operator inserted by the editor. we can split pages with extremely beautiful offset effects. Article content paging article content paging
The pagination code of the php document content is operated based on the pagination characters inserted by the editor. we can split the pages with extremely beautiful offset effects.
Pagination of article content
Pagination of article content
* Author: Chen Kai
* Data: 2010-09-15
* Article paging
*/
Class contentpage
{
Private $ content; // Document content
Private $ pagesize; // minimum number of bytes per page
Private $ breakflag; // page break (customizable, default: n)
Private $ pageurl; // url
Private $ pagevar; // page parameters
Public $ pagecount; // The total number of pages.
Public $ page; // The current page number.
Public $ pagebreak; // start position of each page
Function _ construct ($ content = "", $ pagesize = 10, $ breakflag = "n", $ pageurl = '', $ pagevar = 'p ')
{
$ This-> content = $ content;
$ This-> pagesize = $ pagesize;
$ This-> breakflag = $ breakflag;
$ This-> pageurl = $ pageurl;
$ This-> pagevar = $ pagevar;
$ This-> getpages ();
}
// Total number of pages, start position and end position of each page
Public function getpages ()
{
$ Contentlen = strlen ($ this-> content); // The total number of bytes in the article
$ This-> pagebreak [0] = 0;
$ I = 0;
$ Offset = $ this-> pagesize;
For ($ k = 0; $ k <$ contentlen/$ this-> pagesize; $ k ++)
{
If ($ offset> $ contentlen)
{
$ I ++;
$ This-> pagebreak [$ I] = $ contentlen;
Break;
}
// Find the location where the pagevar appears.
$ Where = strpos ($ this-> content, $ this-> breakflag, $ offset );
If ($ where> $ contentlen or intval ($ where) <1)
{
$ I ++;
$ This-> pagebreak [$ I] = $ contentlen;
Break;
}
Else
{
$ I ++;
$ This-> pagebreak [$ I] = $ where;
$ Offset = $ where + $ this-> pagesize;
}
}
$ This-> pagecount = $ I;
If (isset ($ _ get [$ this-> pagevar]) & $ _ get [$ this-> pagevar]> 1 & $ _ get [$ this-> pagevar] <= $ this-> pagecount)
{
$ This-> page =$ _ get [$ this-> pagevar];
}
Else
{
$ This-> page = 1;
}
}
// Content on each page
Function getpage ()
{
// Truncate the data of the current page number
If ($ this-> page> 1)
{
Return substr ($ this-> content, $ this-> pagebreak [$ this-> page-1] + 1, $ this-> pagebreak [$ this-> page]-$ this-> pagebreak [$ this-> page-1]);
}
Else
{
Return substr ($ this-> content, $ this-> pagebreak [$ this-> page-1], $ this-> pagebreak [$ this-> page]-$ this-> pagebreak [$ this-> page-1]);
}
}
// Pagination bar
Public function getpagenav ()
{
If ($ this-> page> 1)
{
$ Pagenav = "geturl ()." = ". ($ this-> page-1)." 'class = 'p'> Previous page ";
}
// Output the number page number
For ($ j = 1; $ j <= $ this-> pagecount; $ j ++)
{
If ($ j = $ this-> page)
{
$ Pagenav. = "". $ j ."";
}
Else
{
$ Pagenav. = "geturl ()." = ". $ j." 'class = 'p'> ". $ j ."";
}
}
// Next page
If ($ this-> page <$ this-> pagecount & $ this-> pagecount> 1)
{
$ Pagenav. = "geturl ()." = ". ($ this-> page + 1)." 'class = 'p'> next page ";
}
Return $ pagenav;
}
// Obtain the url
Public function geturl ()
{
$ Url = $ _ server ['request _ uri '];
$ Parse_url = parse_url ($ url );
$ Query_url = $ parse_url ['query'];
If ($ query_url)
{
$ Query_url = ereg_replace ("(^ | &)". $ this-> pagevar. "=". $ this-> page, "", $ query_url );
$ Url = str_replace ($ parse_url ['query'], $ query_url, $ url );
If ($ query_url)
{
$ Url. = "&". $ this-> pagevar;
}
Else
{
$ Url. = $ this-> pagevar;
}
}
Else
{
$ Url. = "? ". $ This-> pagevar;
}
Return $ url;
}
}
$ Content = "page 1: The article content is displayed in pages. Aston is a waste of space. Aston is a waste of supervision fees.
Page 2: Aston room. both parties know. for saradevelopment, remember who will make the payment so that the other party's space will come to Fujian and Alibaba?
Page 3
Page 4: Irwin detected that the content of the article is not displayed on pages according to Lhasa and launched by both parties. ";
$ Model = new contentpage ($ content );
Echo $ model-> getpage (); // output the page content
Echo $ model-> getpagenav (); // output page number
?>
Http://www.bkjia.com/PHPjc/444849.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/444849.htmlTechArticlephp article content paging code, is based on the editor inserted by the paging operator to operate, we can split the ultra-beautiful offset effect of the page. Article content pagination article content pagination php Tutorial...