PHP内容页实现分页的代码

  1. <?php? ?
  2. $contents=”fjka;fjsa;#page#批量生[newpage]#page#成分成文#page#件并且加#page#上分页代码”;???//带了分页标签的原内容 ?
  3. $cons=”fjka;fjsa;adsfasdfas码”;??//不带分页标签的原内容 ?
  4. ?
  5. function????conpage($contents)?{ ?
  6. ????$pagesss=’#page#’;??//设定分页标签 ?
  7. ????$a=strpos($contents,$pagesss); ?
  8. ????if($a){ ?
  9. ????$con=explode($pagesss,$contents); ?
  10. ????$cons=count($con);? ?
  11. ????@$p?=?ceil($_GET[‘p’]); ?
  12. ????if(!$p||$p<0)?$p=1; ?
  13. ????$url=$_SERVER[“REQUEST_URI”]; ?
  14. ????$parse_url=parse_url($url); ?
  15. ????$url_query=$parse_url[“query”]; ?
  16. ????if($url_query){ ?
  17. ????$url_query=ereg_replace(“(^|&)p=$p”,””,$url_query); ?
  18. ????$url=str_replace($parse_url[“query”],$url_query,$url); ?
  19. ????if($url_query)?$url.=”&p”;?else?$url.=”p”; ?
  20. ????}else?{ ?
  21. ????$url.=”?p”; ?
  22. ????} ?
  23. ????if($cons<=1)?return?false;//只有一页时不显示分页 ?
  24. ????$pagenav=”<div?class=\”digg\”>”; ?
  25. ????for($i=1;$i<=$cons;$i++){ ?
  26. ????????if($i==$p){ ?
  27. ????????????$pagenav.='<span?class=”current”>’.$p.'</span>’; ?
  28. ????????}else{ ?
  29. ????????????$pagenav.=”<a?href=’$url=$i’>$i</a>”; ?
  30. ????????} ?
  31. ????} ?
  32. ????$pagenav.=”</div>”; ?
  33. ????return?$con[$p-1].$pagenav; ?
  34. ????}else{ ?
  35. ????return?$contents; ?
  36. ????} ?
  37. } ?
  38. ?
  39. echo?????conpage($contents);?//带有分页标签的 ?
  40. echo?????conpage($cons);??//不带分页标签的 ?
  41. ?
  42. ?>??

Copyright © All Rights Reserved · Proudly powered by WordPress 冀ICP备12019045号-1

css.php