: This article mainly introduces the paging and url functions of php high ai. if you are interested in the PHP Tutorial, please refer to them. This paging function is very high.
Let's see.
Function ppage ($ total, $ page, $ e_page = 15, $ e_block = 10, $ url = '', $ color = ''){
If (! Strpos ($ url ,'? '))
$ Url. = '? ';
Else
$ Url. = '&';
If ($ color <> ''){
$ Color = '';
$ Colore = '';
}
$ Totalpage = ceil ($ total/$ e_page); // Number of pages
$ P_block = ceil ($ totalpage/$ e_block); // number of blocks
$ N_block = ceil ($ page/$ e_block); // the current block
$ Start = ($ n_block-1) * $ e_block + 1;
$ Ended = $ n_block * $ e_block;
If ($ ended> $ total)
$ Ended = $ totalpage;
If ($ n_block> 1 ){
$ Link = $ start-1;
$ Head = ''. $ color. '[<=]'. $ colore .'';
}
If ($ n_block <$ p_block ){
$ Link = $ ended + 1;
$ Foot = ''. $ color. '[=>]'. $ colore .'';
}
For ($ I = $ start; $ I <= $ ended; $ I ++ ){
$ Middle. = ''. $ color. '['. $ I. ']'. $ colore .'';
}
Return $ head. $ middle. $ foot;
}
The following describes how to obtain the current url.
Function geturl (){
$ Headers = getallheaders ();
$ Url = 'http: // '. $ headers ['host']. $ SCRipT_NAME;
Return $ url;
}
The above introduces the paging functions and url functions of php high ai, including the paging functions, and hopes to help those who are interested in PHP tutorials.