[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 |
|
07 |
|
08 |
<meta http-equiv="</code">
<code class="php string">"Content-Type"content="text/html; charset=UTF-8"/> |
09 |
<title>www.qqview.com-Read Result</title> |
10 |
<style type="</code"><code class="php string">"text/css"</style>>
|
11 |
<!-- |
12 |
.STYLE1 {font-size: 12px} |
13 |
.STYLE2 {font-size: 18px} |
14 |
--> |
15 |
|
16 |
|
17 |
|
18 |
<table width="</code">
<code class="php string">"100%"bgcolor="#CCCCCC">
|
19 |
|
20 |
|
21 |
<?php |
22 |
if($page){
|
23 |
$counter=file_get_contents("example.txt"); //-------read the file into a string.-------
|
24 |
$length=strlen($counter);
|
25 |
<code class="php variable">$page_count=ceil($length/5000);
|
26 |
|
27 |
functionmsubstr($str,$start,$len){
|
28 |
<code class="php variable">$strlength=$start+$len;
|
29 |
$tmpstr="";
|
30 |
for($i=0;$i<code class="php variable">$strlength;$i++) {
|
31 |
if(ord(substr($str,$i,1))==0x0a) {
|
32 |
$tmpstr.='<br>';
|
33 |
}
|
34 |
if(ord(substr($str,$i,1))>0xa0) {
|
35 |
$tmpstr.=substr($str,$i,2);
|
36 |
$i++;
|
37 |
}
|
38 |
else{
|
39 |
$tmpstr.=substr($str,$i,1); }
|
40 |
}
|
41 |
return$tmpstr;
|
42 |
} |
43 |
//--------------------------截取中文字符串-------------------------- |
44 |
$c=msubstr($counter,0,($page-1)*5000);
|
45 |
$c1=msubstr($counter,0,$page*5000);
|
46 |
echosubstr($c1,strlen($c),strlen($c1)-strlen($c));
|
47 |
}?> |
48 |
|
49 |
|
50 |
|
51 |
|
52 |
<table width="</code">
<code class="php string">"100%"bgcolor="#cccccc">
|
53 |
|
54 |
<td width="</code">
<code class="php string">"42%"align="center"valign="middle"><span><code class="php keyword">class="STYLE1"> <?php echo$page;?> / <?php echo;?> 页
|
55 |
<td width="</code">
<code class="php string">"58%"height="28"align="left"valign="middle">
|
56 |
|
57 |
<?php |
58 |
echo"首页;
|
59 |
if($page!=1){
|
60 |
echo"<a href="m.php?page=%22</code"><code class="php plain">.($page-1).">上一页;
|
61 |
} |
62 |
if($page<code class="php variable">$page_count){
|
63 |
echo"<a href="m.php?page=%22</code"><code class="php plain">.($page+1).">下一页;
|
64 |
} |
65 |
echo"<a href="m.php?page=%22</code"><code class="php plain">.<code class="php variable">$page_count.">尾页";
|
66 |
?> |
67 |
|
68 |
|
69 |
|
70 |
|
71 |
|
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号