PHP實現的超長文本分頁顯示功能示例_第1頁
PHP實現的超長文本分頁顯示功能示例_第2頁
PHP實現的超長文本分頁顯示功能示例_第3頁
PHP實現的超長文本分頁顯示功能示例_第4頁
全文預覽已結束

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

第PHP實現的超長文本分頁顯示功能示例本文實例講述了PHP實現的超長文本分頁顯示功能。分享給大家供大家參考,具體如下:

一、代碼

1、index.php

phpif($_GET['page']==""){$_GET['page']=1;};include("function.php");

html

head

metahttp-equiv="Content-Type"content="text/html;charset=gb2312"/

title超長文本的分頁顯示/title

/head

styletype="text/css"

body{

margin-left:0px;

margin-top:0px;

margin-right:0px;

margin-bottom:0px;

a:link{

text-decoration:none;

a:visited{

text-decoration:none;

a:hover{

text-decoration:none;

a:active{

text-decoration:none;

.STYLE3{color:#333333;font-size:13px;}

/style

body

tablewidth="876"height="638"border="0"align="center"cellpadding="0"cellspacing="0"

tdwidth="343"height="159"nbsp;/td

tdwidth="489"nbsp;/td

tdwidth="44"nbsp;/td

/tr

tdheight="245"nbsp;/td

tdalign="center"valign="top"tablewidth="480"border="0"cellspacing="0"cellpadding="0"

tdheight="22"colspan="2"

span

//讀取超長文本中的數據,實現超長文本中數據的分頁顯示

if($_GET['page']){

$counter=file_get_contents("file/file.txt");

$length=strlen($counter);

$page_count=ceil($length/950);

$c=msubstr($counter,0,($_GET['page']-1)*950);

$c1=msubstr($counter,0,$_GET['page']*950);

echosubstr($c1,strlen($c),strlen($c1)-strlen($c));

/span/td

/tr

tdwidth="202"height="22"span頁次:phpecho$_GET['page'];/phpecho$page_count;頁/span/td

tdwidth="278"span分頁:

if($_GET['page']!=1){

echo"ahref=index.phppage=1首頁/anbsp;";

echo"ahref=index.phppage=".($_GET['page']-1)."上一頁/anbsp;";

if($_GET['page']$page_count){

echo"ahref=index.phppage=".($_GET['page']+1)."下一頁/anbsp;";

echo"ahref=index.phppage=".$page_count."尾頁/a

/span/td

/tr

/table

/td

tdnbsp;/td

/tr

tdheight="234"nbsp;/td

tdnbsp;/td

tdnbsp;/td

/tr

/table

/body

/html

2、function.php

//定義一個用于截取一段字符串的函數msubstr()

functionmsubstr($str,$start,$len){//$str指的是字符串,$start指的是字符串的起始位置,$len指的是長度。

$strlen=$start+$len;//用$strlen存儲字符串的總長度(從字符串的起始位置到字符串的總長度)

for($i=0;$i$strlen;$i++){//通過for循環(huán)語句,循環(huán)讀取字符串

if(ord(substr($str,$i,1))0xa0){//如果字符串中首個字節(jié)的ASCII序數值大于0xa0,則表示為漢字

$tmpstr.=substr($str,$i,2);//每次取出兩位字符賦給變量$tmpstr,即等

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
  • 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論