【www.gdgbn.com--php函数】

  1. <%    "==============================================   
  2. "函数名:contentpage    "作  用:内容分页   
  3. "参  数:1、ocontent ----- 文章内容    "   2、olink  ----- 链接   
  4. "整  理:www.asp教程program.cn    "原创文章,转载请保留此信息,谢谢   
  5. "==============================================      
  6. function contentpage(ocontent, olink)        dim outstr, arrcontent, nextpage, arrpage   
  7.     if instr(ocontent, "[nextpage]") <= 0 then           outstr = ocontent   
  8.     else           nextpage = request("nextpage")   
  9.         arrcontent = split(ocontent, "[nextpage]")            arrpage = ubound(arrcontent) + 1   
  10.         if (nextpage = "" or isnull(nextpage) or not isnumeric(nextpage)) then               nextpage = 1   
  11.         else               nextpage = cint(nextpage)   
  12.         end if           if nextpage < 1 then  
  13.             nextpage = 1            end if  
  14.         if nextpage > arrpage then               nextpage = arrpage   
  15.         end if           outstr = arrcontent(nextpage - 1)   
  16.         outstr = outstr "
    "           for iii = 1 to arrpage   
  17.             if iii = nextpage then                   outstr = outstr ""&iii" "  
  18.             else                   outstr = outstr """&olink"nextpage="&iii""">"&iii" "  
  19.             end if           next  
  20.     end if       contentpage = outstr   
  21. end function     
  22. "=================demo==================    dim sstrhtml, ostrhtml   
  23. sstrhtml = "我的名字叫胡浪[nextpage]胡是古月的胡[nextpage]浪是三点水一个良字的浪[nextpage]不是一个帅哥哦[nextpage]很普通的一个人"   ostrhtml = "我的名字叫胡浪,胡是古月的胡,浪是三点水一个良字的浪,不是一个帅哥哦,很普通的一个人"  
  24. "=================demo==================    response.write("------------------- 带分页 ---------------------")   
  25. response.write("
    ")    response.write(contentpage(sstrhtml, "?"))   
  26. response.write("
    ")    response.write("------------------- 不带分页 ---------------------")   
  27. response.write("
    ")    response.write(contentpage(ostrhtml, "?"))   
  28. %>  

本文来源:http://www.gdgbn.com/jiaocheng/27681/