This example of this article for you to share the PHP implementation of file content operation of the paging class, emphasize the file only for the operation, for your reference, the specific content as follows
<?php class Strpage {private $current; Current page private $file; Operation File Private $totalPage; Total number of pages private $url; The parameters passed are private $pageLen;
The length of the display on each page function __construct ($file, $len =) {$this->file = file_get_contents ($file);
$this->pagelen = $len;
$this->current = isset ($_get[' page ')? $_get[' page ']:1;
$this->totalpage = $this->gettotalpage ();
$this->url = $this->geturl ();
//Get to the total length of this file private function Gettotalpage () {return ceil (strlen ($this->file)/$this->pagelen);
//Gets the currently passed parameter, retains the parameter, the page parameter dynamically changes private function GetUrl () {$url =parse_url ($_server[' Request_uri '));
Parse_str ($url [' query '], $QUERYARR);
unset ($queryArr [' page ']);
$QUERYSTR = Http_build_query ($QUERYARR); return $url [' Path ']. $queryStr. '
&page= '; //Home Private Function First () {if ($this->current>1) return "<a href=". $this->url. "
1 ' > Home </a> '; //Previous Private Function pre () {if ($this->current > 1) return "<a href= ' ". $this->url. ($this->current-1). "'
> Prev </a> "; //Next page Private function next () {if ($this->current < $this->totalpage) return "<a href=". $this->url. ($this->current+1). "'
> next page </a> "; //Last page Private Function end () {if ($this->current < $this->totalpage) return "<a href=". $this->url . $this->totalpage. "'
> Last </a> ";
The Public Function pagelist () {$pageListStr = '; For ($i =1 $i <= $this->totalpage; $i + +) {if ($i = = $this->current) {$pageListStr. = "<span style=" font-size : 20px;color: #f00 ' > '. $i. "
</span> "; }else{$pageListStr. = "<a href=". $this->url. $i. "' > ". $i."
</a> ";
} return $PAGELISTSTR; The Public Function Pagestyle ($style =1) {switch ($style) {case 1:return "total". $this->totalpage. "
Page ". $this->first (). $this->pre (). $this->pagelist (). $this->next (). $this->end ();
Break
Case 2;
return $this->pagelist ();
Break The Public Function getcontents () {$prePageLen = strlen ($this->substrs ($this->current-1));
$currentPageLen = strlen ($this->substrs ($this->current));
Return substr ($this->file, $prePageLen, $currentPageLen-$prePageLen);
The Public Function Substrs ($page) {$string = ';
$len = $page * $this->pagelen; For ($i =0 $i < $len $i + +) {if Ord (substr ($this->file, $i, 1) >0xa0) {$string. = substr ($this->file, $i, 3
);
$i = $i +2;
}else{$string. = substr ($this->file, $i, 1);
} return $string; }
}
Wonderful topic sharing:PHP paging function Operation
The above is the entire content of this article, I hope that you learn PHP programming help.