The example of this article for you to share the PHP implementation of the file contents of the paging class, emphasizing that only the operation of the file for your reference, the specific content as follows
<?php class Strpage {private $current; Current page private $file; Operation File Private $totalPage; The total number of pages private $url; Parameters passed to private $pageLen; Length per 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 parameters, retains the parameters, and the page parameter dynamically changes the 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 "URL." 1 ' > Home "; }//Previous Private Function pre () {if ($this->current > 1) return "URL. ( $this->current-1). "' > Previous page "; }//Next Private Function next () {if ($this->current < $this->totalpage) return "URL. ($this->current+1). "' > next Page "; }//last page Private Function end () {if ($this->current < $this->totalpage) return "URL. $this->totalpage." > Last "; The Public Function pagelist () {$pageListStr = ""; for ($i =1; $i <= $this->totalpage; $i + +) {if ($i = = $this->current) { $pageListStr. = "". $i.""; }else{$pageListStr. = "URL. $i." > ". $i." "; }} return $pageListStr; Public Function Pagestyle ($style =1) {switch ($style) {case 1:return "common". $this->totalpage. " Page. $this->first (). $this->pre (). $this->pagelist (). $this->next (). $this->end (); Break Case 2; return $this->pagelist (); Break }} Public Function getcontents () {$prePageLen = strlen ($this->substrs ($this->current-1)); $currentPageLen = Strle N ($this->substrs ($this->current)); Return substr ($this->file, $prePageLen, $currentPageLen-$prePageLen); 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; } }
Special topic Sharing: PHP paging function operation
The above is the whole content of this article, I hope that you learn PHP programming help.
The above describes the init.php file PHP implementation for the file content operation of the paging class, including the contents of the init.php file, I hope to be interested in PHP tutorial friends helpful.