Php article page. 1 .? Php2. * article paging code * 3.4.20.fpfopen(txt.txt, r); 5. while (! Feof ($ fp) {6. $ content. fgets ($ fp); 7 .} 8. $ c_page; 9.if( isset ($ _ GET [page]) $ c_page $ _ GET [page]; 10. $ listlen1 1. 2./* article paging code */
3.
4. export fpw.fopen('txt.txt ', 'r ');
5. while (! Feof ($ fp )){
6. $ content. = fgets ($ fp );
7 .}
8. $ c_page = "";
9. if (isset ($ _ GET ['Page']) $ c_page = $ _ GET ['Page'];
10. $ listlen = 100; // Number of characters displayed by page
11. $ conlen = strlen ($ content); // content length
12. $ j = 0;
13. $ listat [0] = 0;
14. $ lookat = 0;
15. for ($ I = 1; $ I <$ conlen/$ listlen + 1; $ I ++ ){
16. // echo $ conlen/$ listlen;
17. if ($ lookat <$ listlen)
18. $ lookat = $ listlen;
19. if ($ lookat> $ conlen ){
20. $ j ++;
21. $ listat [$ j] = $ conlen;
22. break;
23 .}
24. $ endat = strpos ($ content, "\ n", $ lookat );
25. if ($ endat> $ conlen-$ listlen/5 or intval ($ endat) <1 ){
26. $ j ++;
27. $ listat [$ j] = $ conlen;
28. break;
29.} else {
30. $ j ++;
31. $ listat [$ j] = $ endat;
32. $ lookat = $ endat + $ listlen;
33 .}
34.
35 .}
36. // print page
37. $ pagenum = $ j; // total number of pages
38. $ page = intval ($ c_page );
39. if (emptyempty ($ page) or $ page <1 or $ page> $ pagenum) $ page = 1;
40. if ($ pagenum> 1)
41. for ($ I = 1; $ I <$ pagenum + 1; $ I ++ ){
42. echo "{$ I }";
43 .}
44. echo"
";
45. $ stag = $ page-1;
46. $ startb = $ listat [$ stag];
47. if ($ startb> 0) // remove the first line feed www.2cto.com
48. $ startb = $ startb + 1;
49. $ cont = substr ($ content, $ startb, $ listat [$ page]-$ startb );
50. echo"
Article content:
";
51. if ($ page> 1)
52. echo "[next to the previous page]";
53. echo $ cont;
54.
55.?>
Author: chaojie2009
Http://www.bkjia.com/PHPjc/478163.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/478163.htmlTechArticle1 .? Php 2./* article paging code */3. 4.20.fp1_fopen(txt.txt, r); 5. while (! Feof ($ fp) {6. $ content. = fgets ($ fp); 7 .} 8. $ c_page =; 9.if( isset ($ _ GET [page]) $ c_page = $ _ GET [page]; 10. $ listlen = 1...