Home >php教程 >php手册 >php开发必须分页代码

php开发必须分页代码

WBOY
WBOYOriginal
2016-06-13 10:00:28834browse

在开发中这个分页功能肯定是少不了的,今天我们分享一个非常实用且简单的php分页功能的实现代码,有需要的朋友可以参考一下。

 代码如下 复制代码

/**
* 分页函数
*
* @param int $count 条目总数
* @param int $perlogs 每页显示条数目
* @param int $page 当前页码
* @param string $url 页码的地址
*/
function pagination($count,$perlogs,$page,$url,$anchor=''){
$pnums = @ceil($count / $perlogs);
$re = '';
$urlHome = preg_replace("|[?&/][^./?&=]*page[=/-]|","",$url);
for ($i = $page-5;$i if ($i > 0){
if ($i == $page){
$re .= " $i ";
} elseif($i == 1) {
$re .= " $i ";
} else {
$re .= " $i ";
}
}
}
if ($page > 6) $re = "«...$re";
if ($page + 5 ... »";
if ($pnums return $re;
}
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