一個(gè)高ai的分頁函數(shù)與一個(gè)url函數(shù)
發(fā)表時(shí)間:2024-01-10 來源:明輝站整理相關(guān)軟件相關(guān)文章人氣:
[摘要]這個(gè)分頁函數(shù)非常高只能的 看看就知道了 function ppage(total, page, e_page = 15, e_block = 10, url = '', color = '') if(!strpos(url,'?')) ur...
這個(gè)分頁函數(shù)非常高只能的
看看就知道了
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 = '</font>';
}
$totalpage = ceil($total/$e_page); //頁面數(shù)目
$p_block = ceil($totalpage/$e_block); //塊數(shù)目
$n_block = ceil($page/$e_block); //現(xiàn)在塊
$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 ='<a href='.$url.'page='.$link.'>'.$color.'[<=]'.$colore.'</a> ';
}
if($n_block<$p_block) {
$link = $ended+1;
$foot = '<a href='.$url.'page='.$link.'>'.$color.'[=>]'.$colore.'</a>';
}
for($i=$start;$i<=$ended;$i++) {
$middle .='<a href='.$url.'page='.$i.'>'.$color.'['.$i.']'.$colore.'</a> ';
}
return $head.$middle.$foot;
}
下面是取得當(dāng)前url的方法
function geturl() {
$headers = getallheaders();
$url = 'http://'.$headers['Host'].$SCRIPT_NAME;
return $url;
}