-
Notifications
You must be signed in to change notification settings - Fork 0
/
25.php
51 lines (50 loc) · 1.63 KB
/
25.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<html>
<head>
</head>
<body>
<body>
<div id="header">
<b>文本文件内容分页显示</b>
</div>
<div id="content">
<div id="show">
<p>
<?php
/*此处省略自定义函数m_substr()具体实现*/
if(isset($_GET['page']))
{
$page=$_GET['page'];
}else{
$page=1;
}
$counter=file_get_contents("example.txt");
$length=strlen($counter);
$page_count=ceil($length/400);
$str=m_substr($counter,0,($page-1)*400);
$str1=m_substr($counter,0,$page*400);
echo substr($str1,strlen($str),strlen($str1)-strlen($str));
?>
</p>
</div>
<center>
<span>
<?php
echo "当前页:".$page."/".$page_count." ";
echo "<a herf=index.php?page=1>首页</a>";
if($page>1)
{
echo "<a herf=index.php?page=".($page-1).">上一页</a>";
}
if($page<$page_count)
{
echo "<a herf=index.php?page=".($page+1).">下一页</a>";
}
echo "<a herf=index.php?page=".$page_count.">尾页</a>";
?>
</span>
</center>
</div>
<div id="footer"><br />文本分页</div>
</body>
</body>
</html>