使用 PHP 读取文本(TXT)文件 并分页显示

使用 PHP 读取文本(TXT)文件 并分页显示,第1张

view source   print?<?php // you should save this file as m php      session_start()       if ( empty ( $page )) { $page = }      if (isset( $_GET [ page ])==TRUE) { $page = $_GET [ page ]} ?>  <>  <head>  <meta equiv= "Content Type" content= "text/charset=UTF " />  <title>qqview Read Result</title>  <style type= "text/css" >  <!   STYLE {font size: px}  STYLE {font size: px}  >  </style>  </head>  <body>  <table width= " %"   bgcolor= "#CCCCCC" >  <tr>  <td >  <?php  if ( $page ){  $counter = file_get_contents ( "example txt" ) // 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 ))== x a) {           $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 ( $c strlen ( $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=m php?page= >首页</a>"    if ( $page != ){       echo "<a href=m php?page=" ( $page ) ">上一页</a>"   }  if ( $page < $page_count ){       echo "<a href=m php?page=" ( $page + ) ">下一页</a>"   } echo "<a href=m php?page="$page_count">尾页</a>"    ?>  </span></td>  </tr>  </table>  </body>  </> lishixinzhi/Article/program/PHP/201311/21215

<?php(http://houdunwang.com/lesson.html)

// 创建一个新的pdf文档句柄

$pdf = pdf_new()

// 打开一个文件

pdf_open_file($pdf, "pdftest.pdf")

// 开始一个新页面(a4)

pdf_begin_page($pdf, 595, 842)

// 得到并使用字体对象

$arial = pdf_findfont($pdf, "arial", "host", 1)

pdf_setfont($pdf, $arial, 10)

// 输出文字

pdf_show_xy($pdf, "this is an exam of pdf documents, it is a good lib,",50, 750)

pdf_show_xy($pdf, "if you like,please try yourself!", 50, 730)

echo "<a href=m.php?page=1>首页</a>"

if($page!=1){

echo "<a href=m.php?page=".($page-1).">上一页</a>"

}

if($page<$page_count){

echo "<a href=m.php?page=".($page+1).">下一页</a>"

}

echo "<a href=m.php?page=".$page_count.">尾页</a>"

// 结束一页

pdf_end_page($pdf)

// 关闭并保存文件

pdf_close($pdf)

?>更多问题到问题求助专区http://bbs.houdunwang.com/


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/tougao/11915634.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-19
下一篇 2023-05-19

发表评论

登录后才能评论

评论列表(0条)

保存