PHP text article paging code by tag or length (does not involve databases ). Example code: Copy the code as follows :? Php *************************************** * ********************** ReadMe * article paging ** by page, you can paging by words and by instance code:
The code is as follows:
/**
**************************************** *******************
* 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.
* You can write a powerful function to save it as needed.
*
* Digression: Many editors use the insert page button to display pages using the inserted code.
*
* Filename: page. php
* Charset: UTF-8
* Create date: 2012-5-16
**************************************** *******************
* @ Author itbdw
* @ Copyright (C) 2011-2012 itbdw
* @ Link http://weibo.com/itbudaoweng
*/
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
The pipeline code is as follows :? Php /************************************** * *********************** Read Me * article paging ** by page, you can paging by words,...