萬盛學電腦網

 萬盛學電腦網 >> 網絡編程 >> php編程 >> 使用 PHP 讀取文本(TXT)文件 並分頁顯示

使用 PHP 讀取文本(TXT)文件 並分頁顯示

[PHP]代碼

view source   print? 01 <?php //----------------you should save this file as m.php---------------- 02     session_start();  03     if (empty($page)) {$page=1;} 04     if (isset($_GET['page'])==TRUE) {$page=$_GET['page']; } 05 ?>  06 <html>  07 <head>  08 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />  09 <title>www.qqview.com-Read Result</title>  10 <style type="text/css" 11 <!--  12 .STYLE1 {font-size: 12px}  13 .STYLE2 {font-size: 18px}  14 -->  15 </style>  16 </head>  17 <body>  18 <table width="100%"  bgcolor="#CCCCCC" 19 <tr>  20 <td >  21 <?php  22 if($page){  23 $counter=file_get_contents("example.txt"); //-------read the file into a string.------- 24 $length=strlen($counter);  25 $page_count=ceil($length/5000);  26   27 function msubstr($str,$start,$len){  28     $strlength=$start+$len 29     $tmpstr=""; 30     for($i=0;$i<$strlength;$i++) {  31     if(ord(substr($str,$i,1))==0x0a) {  32         $tmpstr.='<br />'; 33 &nbs
copyright © 萬盛學電腦網 all rights reserved