又一款php分页代码 以前写过很多php 分页类但是今天这款分页程序我感觉是很好的,简洁实用,代码合理并没有多余的代码,是一款不错分页类函数哦。
又一款php教程分页代码
以前写过很多php 分页类但是今天这款分页程序我感觉是很好的,简洁实用,代码合理并没有多余的代码,是一款不错分页类函数哦。
*/
class multipage { var $total; var $perpage; var $pages; var $maxpage; var $offset = 9; var $curr_page; function init($total, $perpage, $maxpage) { //初始化页数 $this->total; $this->perpage; $this->maxpage; $this->offset = 9; } function getpagelist() {//获取分页列表 $result_pages = ""; $this->pages = ceil($this->total / $this->perpage); if ($this->pages > $this->maxpage) { $from = $this->curr_page - $this->offset; if ($from maxpage - 1; if ($to > $this->pages) { $to = $this->pages; if (($to - $from) maxpage) { $from = $from - 1; } } } else { $from = 1; $to = $this->pages; } $p = 0; for($i = $from; $i curr_page > 1 && $this->pages > 1) { return 1; } else { return ""; } } function getlast() { //取末页 if ($this->pages > 1 && $this->curr_page pages) { return $this->pages; } else { return ""; } } function getprev() {//上一页 $prevpage = $this->curr_page - 1; if ($prevpage > 0) { return $prevpage; } else { $prevpage = ""; return $prevpage; } } function getnext() {//下一页 $nextpage = $this->curr_page + 1; if ($nextpage pages) { return $nextpage; } else { $nextpage = ""; return $nextpage; } } function gettotal() {//共多少页 if ($this->pages > 0) { return $this->pages; } else { return 1; } } } //分页类的使用方法 $page = new multipage(); $page->gettotal(); //总页娄 $page->getnext();//下一页
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号