下面要提供了是一款常用的php 常用分页代码哦,功能全面。
function multi($total, $perPage, $curPage, $pageUrl, $maxPages = 0, $page = 10, $autoGoTo = TRUE, $simple = FALSE) {
$multiPage = '';
$pageUrl .= strpos($pageUrl, '?') ? '&' : '?';
$realPages = 1;
if($total > $perPage) {
$offset = 2;
$realPages = @ceil($total / $perPage);
$pages = $maxPages && $maxPages
if($page > $pages) {
$from = 1;
$to = $pages;
} else {
$from = $curPage - $offset;
$to = $from + $page - 1;
if($from
$to = $curPage + 1 - $from;
$from = 1;
if($to - $from
$to = $page;
}
} elseif ($to > $pages) {
$from = $pages - $page + 1;
$to = $pages;
}
}
$multiPage = ($curPage - $offset > 1 && $pages > $page ? '1 ...' : '').
($curPage > 1 && !$simple ? '‹‹' : '');
for($i = $from; $i
$multiPage .= $i == $curPage ? ''.$i.'' :
''.$i.'';
}
$multiPage .= ($curPage ››' : '').
($to ... '.$realPages.'' : '').
(!$simple && $pages > $page && !$ajaxtarget ? '' : '');
$multiPage = $multiPage ? '
function dhtmlspecialchars($string) {
if(is_array($string)) {
foreach($string as $key => $val) {
$string[$key] = dhtmlspecialchars($val);
}
} else {
$string = preg_replace('/&((#(d{3,5}|x[a-fA-F0-9]{4})|[a-zA-Z][a-z0-9]{2,5});)/', '&\1',
str_replace(array('&', '"', ''), array('&', '"', '<', '>'), $string));
}
return $string;
}