PHP Simple implementation of paging function for text files

Source: Internet
Author: User
PHP is simple to implement the paging function of text files

PHP is simple to implement the paging function of text files

    
 
  
     <title>Paging</title>    
 Php//Chinese character handlingfunctionM_SUBSTR ($str,$start,$length){    $str _length=$start+$length;//get total intercept length    $tmp _str= "";  for($i= 0;$i<$str _length;$i++){        if(Ord(substr($str,$i, 1)) = = 0x0a){            $tmp _str.= "
"; } if(Ord(substr($str,$i, 1)) >0xa0){ $tmp _str.=substr($str,$i, 2); $i++; }Else{ $tmp _str.=substr($str,$i, 1); } } return $tmp _str;}//pass-through parameter processingif(isset($_get[' Page '])){ $page=$_get[' Page '];}Else{ $page= 1;}$counter=file_get_contents("Example.txt");$length=strlen($counter);$page _count=Ceil($length/400);$pre _str= M_substr ($counter, 0, ($page-1) *400);$now _str= M_substr ($counter, 0,$page*400);Echo substr($now _str,strlen($pre _str),strlen($now _str)-strlen($pre _str));Echo"

";EchoThe current page.$page." /".$page _count;Echo"Index";if($page>1){ Echo"$page-1). "' >pre ";}if($page<$page _count){ Echo"$page+1). " >next ";}Echo"$page _count>end ";?>

  • Related Article

    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.