PHP Page-Out class

Source: Internet
Author: User

<?php //page Category class page{    private  $total _rows; //total number of bars      private  $onepage _rows;//page Display quantity     private  $total total pages _page; //     private  $page _rows; //page Count     private  $start _id;// Description start id    private  $end _id;//description End id    private  $desc  =   ";  //description Previous, next     private  $self _page; //current page      private  $url;     public function __construct ($total, $onepage _rows=10, $page _ rows=5, $desc = ") {         $this->total_rows =  $total;          $this->onepage_rows =  $onepage _rows;          $this->page_rows =  $page _rows;          $this-> Total_page = ceil ($this->total_rows /  $this->onepage_rows);          $this->self_page = min (max ((int) @$_get[' page '],1), $this->total_page);          $this->start_id=  ($this->self_page-1) * $this onepage_rows+1;         $this->end_id= min ($this->self_page* $this->onepage_rows ,  $this->total_rows);         $ this->desc =  $this->desc ($DESC);  //prev   Next   total x Records           $this->url =  $this->requesturl ();  //url generation      }    private function requesturl () {          $url  =isset ($_server[' Request_uri ')  ? $_server[' Request_uri '] : $_server[' PHP_ Self ']. '? '. $_server[' QUERY_string '] ;         $parse _url = parse_url ($url);         if (isset ($parse _url[' query ')) {             parse_str ($parse _url[' query '], $arr);             unset ($arr [' page ']);              $url  =   $parse _url[' path '] . '? '. Http_build_query ($arr). ' &page= ';        }else{              $url  = strstr ($url, '? ')  ?   $url. ' Page= '  : $url .  '? page= ';        }             return  $url;    }     //Specifies the list page number     public function&Nbsp;pagelist () {           $start =max (1,min ($this->self_ Page-ceil ($this->page_rows/2), $this->total_page-$this->page_rows));          $end = $start  +  $this->page_rows;         $arr  = array ();         for ($i = $start;  $i <= $end;   $i + +) {            if ($i  ==  $this- >self_page) {                  $arr [$i] [' url '] =  ';                  $arr [$i] [' str '] =  $i;                 continue;             }             $arr [$i] [' url '] =  $this->url. $i;              $arr [$i] [' str '] =  $i;         }        return  $arr;     }    //string representation of the return code list     public function  Pageshow () {         $pagelist  =  $this->pagelist ();          $pagestr  =  ';         foreach ($pagelist  as  $v) {             if (Empty ($v [' url ')]) {                  $pagestr  .=  ' <strong> ' $v [' str ']. ' </strong> ';                 continue;             }             $pagestr  .=  " <a href= '. $v [' url ']. "' > ". $v [' str ']." </a> ";        }         return  $pagestr;     }    public function desc ($DESC) {          $d  = array (' prev '  =>  ' previous ', ' Next '   =>  ' next page ', ' first ' =>  ' home ', ' last '  =>  ' end ');         if (Empty ($desc)  | |  !is_array ($DESC)) { return  $d;}         function filter ($v) {             return !empty ($v);         }& NBsP;       return array_merge ($d, Array_filter ($desc, ' Filter '));     }     //Home     public function first () {        return  $this->self_page > 1 ?  ' <a href= '. $this->url. ' 1 "> $this->desc[' First ']. ' </a> ': ';     }         //last      public function last () {        return $ this->self_page <  $this->page_rows ?  ' <a href= '. $this->url. $this Page_rows. ' " > '. $this->desc[' last ']. ' </a> ': ';     }    //page     public  Function prev () {        return  $this->self_page >  1 ?  ' &Lt;a href= "'. $this->url. ($this->self_page-1). ' " > '. $this->desc[' prev '). ' </a> ': ';     }    //next     public  Function next () {        return  $this->self_page <   $this->total_page ?  ' <a href= '. $this->url. ($this->self_page+1). ' " > '. $this->desc[' next '. ' </a> ': ';     }    //return to the current section x-x     public  function nowpage () {        return  ' current section '. $this->self _page. ' Page   $this->start_id. ' --'. $this->end_id. '     }    public function limit () {         return  ' limit  '. Max (0, ($this->self_page-1) * $this->onepage_rows). ', '. $ This->onepage_rows;    }} ?>


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.