Php text article paging code example
- /**
- **************************************** *******************
- * Read Me
- * Article pagination
- *
- * Paging mode: Paging by words, line feed, and special mark
- * In fact, the implementation idea is the same, just put it into an array according to a certain rule
- * Obtain a part based on the parameters passed in by the url.
- *
- *
- * Filename: page. php
- * Charset: UTF-8
- * Create date: 2012-5-16
- **************************************** *******************
- * @ Author itbdw
- * @ Copyright (C) 2011-2012 itbdw
- * @ Link http://weibo.com/itbudaoweng
- * @ Url http://bbs.it-home.org
- */
- Header ('content-Type: text/html; charset = utf-8 ');
- ?>
- $ Title = 'pagination test ';
- // The data to be paged
- $ Data = <Hey, guys. I am here to test if it is working.
- This pagination is very simple, isn' t it?
- And I tried to use different method to page it.
- Can you see it?
- DATA;
- // Current article page
- $ Page = 0;
- // Initial article length
- $ Length = 0;
- // Page length
- $ Perpage = 160;
- // Code displayed on the page
- $ Link = '';
- // Split array
- $ StrArr = array ();
- $ Page = isset ($ _ GET ['Page'])? Intval ($ _ GET ['Page']): 0;
- $ Length = strlen ($ data );
- // Word segmentation
- // $ Str = str_split ($ data, $ perpage );
- // Separate by characters
- $ Delimiter = "\ n ";
- // $ Delimiter = '<-- pagination --> ';
- $ StrArr = explode ($ delimiter, $ data );
- $ StrNum = count ($ strArr );
- $ Content = $ strArr [$ page];
- If ($ strNum> 1 ){
- If ($ page! = 0 ){
- $ Link. = 'homepage ';
- } Else {
- $ Link. = 'homepage ';
- }
- For ($ n = 0; $ n <$ strNum; $ n ++ ){
- If ($ n = $ page ){
- $ Link. = ''. ($ n + 1 ).'';
- } Else {
- $ Link. = "". ($ n + 1 )."";
- }
- }
- $ Link. = '';
- If ($ page! = ($ StrNum-1 )){
- $ Link. = "Last page ";
- } Else {
- $ Link. = 'end page ';
- }
- }
- ?>
-
-
-
-
-
- Test article page
-
-
-
-
-
|