Php article page

Source: Internet
Author: User
Php article pagination & lt ;? Php/* article paging code */javasfpw.fopen('txt.txt ', 'r'); while (! Feof ($ fp) {$ content. = fgets ($ fp) ;}$ c_page = & quot; if (isset ($ _ GET ['Page']) php article pagination
<? Php/* article paging code */javasfpw.fopen('txt.txt ', 'r'); while (! Feof ($ fp) {$ content. = fgets ($ fp) ;}$ c_page = ""; if (isset ($ _ GET ['Page']) $ c_page =$ _ GET ['Page']; $ listlen = 100; // Number of characters displayed by page $ conlen = strlen ($ content); // content length $ j = 0; $ listat [0] = 0; $ lookat = 0; for ($ I = 1; $ I <$ conlen/$ listlen + 1; $ I ++) {// echo $ conlen/$ listlen; if ($ lookat <$ listlen) $ lookat = $ listlen; if ($ lookat> $ conlen) {$ j ++; $ listat [$ j] = $ conlen; break;} $ endat = strpos ($ content, "\ n", $ lookat); if ($ endat> $ conlen-$ listlen/5 or intv Al ($ endat) <1) {$ j ++; $ listat [$ j] = $ conlen; break;} else {$ j ++; $ listat [$ j] = $ endat; $ lookat = $ endat + $ listlen ;}// print page $ pagenum = $ j; // total page size $ page = intval ($ c_page); if (empty ($ page) or $ page <1 or $ page> $ pagenum) $ page = 1; if ($ pagenum> 1) for ($ I = 1; $ I <$ pagenum + 1; $ I ++) {echo "{$ I }";} echo "<br>"; $ stag = $ page-1; $ startb = $ listat [$ stag]; if ($ startb> 0) // remove the first line feed $ startb = $ startb + 1; $ cont = substr ($ content, $ startb, $ listat [$ pag E]-$ startb); echo "<BR/> Content: <BR/>"; if ($ page> 1) echo "[Next page]"; echo $ cont;?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.