zyan/page
简洁好用的php通用分页
要求
- php >= 7.3
- Composer
安装
composer require zyan/page -vvv
快速上手
use Zyan\Page\Page;
$config = [
'total_rows' => 1000, //总条数
'url_rule' => '/list/?.html', //url规则 ? 代替分页数
'now_page' => 50, //当前页
'list_rows' => 10, //一页显示多少条
];
$page = Page($config);
输出html
echo $page->show();
<div class="zyan-page">
<a href="/list/1.html">第一页</a>
<a href="/list/49.html">上一页</a>
<a href="/list/47.html">47</a>
<a href="/list/48.html">48</a>
<a href="/list/49.html">49</a>
<a class='active'>50</a>
<a href="/list/51.html">51</a>
<a href="/list/52.html">52</a>
<a href="/list/53.html">53</a>
<a href="/list/51.html">下一页</a>
<a href="/list/100.html">最后一页</a>
</div>
自定义名称
$config = [
'first_page_name' => '<<', //第一页
'prev_page_name' => '<', //上一页
'next_page_name' => '>', //下一页
'last_page_name' => '>>', //最后一页
//...
];
$page = Page($config);