Home  >  Article  >  Backend Development  >  Score: a high-ai paging function and a url function

Score: a high-ai paging function and a url function

WBOY
WBOYOriginal
2016-07-29 08:33:341051browse

This paging function is very powerful. Just take a look and you will know. function ppage($total, $page, $e_page = 15, $e_block = 10, $url = '', $color = '') {
if( !strpos($url,'?'))
$url.='?';
else
$url.='&';
if($color<>'') {
$color ='< font 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); //Now 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 is the method to get the current url
function geturl() {
$headers = getallheaders();
$url = 'http://'.$headers['Host'].$SCRIPT_NAME;
return $url;
}
The above introduces the score, a high-AI paging function and a url function, including the content of scores. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn