熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> PHP編程 >> 正文

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

2022-06-13   來源: PHP編程 

  [PHP]代碼

view source   print? <?php //you should save this file as mphp     session_start();      if (empty($page)) {$page=;}     if (isset($_GET[page])==TRUE) {$page=$_GET[page]; } ?>  <html>  <head>  <meta httpequiv="ContentType" content="text/html; charset=UTF" />  <title>wwwqqviewcomRead Result</title>  <style type="text/css" <!  STYLE {fontsize: px}  STYLE {fontsize: px}  </style>  </head>  <body>  <table width="%"  bgcolor="#CCCCCC" <tr>  <td >  <?php  if($page){  $counter=file_get_contents("exampletxt"); //read the file into a string $length=strlen($counter);  $page_count=ceil($length/);    function msubstr($str$start$len){      $strlength=$start+$len     $tmpstr="";     for($i=;$i<$strlength;$i++) {      if(ord(substr($str$i))==xa) {          $tmpstr=<br />;     }     if(ord(substr($str$i))>xa) {          $tmpstr=substr($str$i);          $i++;      }     else         $tmpstr=substr($str$i); }           return $tmpstr //截取中文字符串  $c=msubstr($counter($page)*);  $c=msubstr($counter$page*);  echo substr($cstrlen($c)strlen($c)strlen($c));  }?>  </td>  </tr>  </table>    <table width="%"  bgcolor="#cccccc" <tr>  <td width="%" align="center" valign="middle"><span class="STYLE"> <?php echo $page;?> / <?php echo $page_count;?> 頁 </span></td>  <td width="%" height="" align="left" valign="middle"> <span class="STYLE"> <?php echo "<a href=mphp?page=>首頁</a> ";   if($page!=){      echo "<a href=mphp?page="($page)">上一頁</a> " if($page<$page_count){      echo "<a href=mphp?page="($page+)">下一頁</a> " } echo "<a href=mphp?page="$page_count">尾頁</a>";   ?>  </span> </td>  </tr>  </table>  </body>  </html>
From:http://tw.wingwit.com/Article/program/PHP/201311/21215.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.