编程语言
首页 > 编程语言> > php 分页类

php 分页类

作者:互联网

安装分页类库

composer require "jasongrimes/paginator:~1.0"

用法

index.php

<?php
require '../vendor/autoload.php';

use JasonGrimes\Paginator;

$totalItems = 500;  //总页数
$itemsPerPage = 10;  // 每页显示数
$currentPage = 5; // 当前所在页数
$urlPattern = '/foo/page/(:num)';  // 定义跳转地址
$paginator = new Paginator($totalItems, $itemsPerPage, $currentPage, $urlPattern);

?>
<html>
<head>
    <link rel="stylesheet" href="//cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css">
</head>
<body>
<?php
echo $paginator;
?>
</body>
</html>

浏览器显示

标签:类库,paginator,1.0,分页,index,php
来源: https://www.cnblogs.com/hu308830232/p/14944317.html