Home > php教程 > php手册 > body text

一个高ai的分页函数和一个url函数_php基础

WBOY
Release: 2016-05-17 09:07:37
Original
816 people have browsed it

这个分页函数非常高只能的
看看就知道了
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);  //页面数目
$p_block   = ceil($totalpage/$e_block);  //块数目
$n_block   = ceil($page/$e_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.'[ ';
}
if($n_block   $link    = $ended+1;
   $foot    = '
'.$color.'[=>]'.$colore.'';
}
for($i=$start;$i   $middle .=''.$color.'['.$i.']'.$colore.' ';
}
return $head.$middle.$foot;
}
下面是取得当前url的方法
function geturl() {
$headers = getallheaders();
$url     = 'http://'.$headers['Host'].$SCRIPT_NAME;
return $url;

source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!