init.php file PHP implementation for the file content operation of the paging class

Source: Internet
Author: User
Tags learn php learn php programming php programming
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.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.