PHP reads the contents of the text file and displays it in pages,
function is simple, just use PHP to read the text (TXT) file and page display
<?php//----------------You should save this file as m.php----------------session_start (); if (empty ($page)) {$page = 1;} if (Isset ($_get[' page ') ==true) {$page =$_get[' page '];}? >
<title>Read Result</title>
<?php if ($page) {$counter =file_get_contents ("example.t XT "); -------read the file into a string.-------$length =strlen ($counter); $page _count=ceil ($length/5000); function Msubstr ($str, $start, $len) {$strlength = $start + $len; $tmpstr = ""; for ($i =0; $i < $strlength; $i + +) {if (Ord (substr ($str, $i, 1)) ==0x0a) {$tmpstr. = ' '; } if (Ord (substr ($str, $i, 1)) >0xa0) {$tmpstr. =substr ($str, $i, 2); $i + +; } else{$tmpstr. =substr ($str, $i, 1);} } return $TMPSTR; }//--------------------------intercept Chinese strings--------------------------$c =msubstr ($counter, 0, ($page-1) *5000); $c 1=msubstr ($counter, 0, $page *5000); Echo substr ($c 1,strlen ($c), strlen ($c 1)-strlen ($c)); }?> |
<?php echo $page;? >/<?php echo $page _count;? > Page |
<?phpecho "Home"; if ($page!=1) {echo "Prev";} if ($page < $page _count) {echo "next page";} echo "Last";?> |
Articles you may be interested in:
- Code for reading text files under high efficiency PHP
- AJAX real-time Read input text (PHP)
- Read efficiency of PHP text files
- PHP quickly read the package class of CSV large files by line share (also applicable to other oversized text files)
- PHP read Rich text when the P tag will appear red line is what's going on
- thinkphp automatic Escape solution for reading errors caused by storing rich text editor content
- How php reads txt text files and displays them in pagination
http://www.bkjia.com/PHPjc/1087266.html www.bkjia.com true http://www.bkjia.com/PHPjc/1087266.html techarticle PHP Read text file content and page display, the function is very simple, just use PHP read text (TXT) file and page to display PHP//----------------You should save this file as m.php--...