PHP code example of laasti / pagination

1. Go to this page and download the library: Download laasti/pagination library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

laasti / pagination example snippets



$pagination = new Pagination($currentPage, $total, $perPage, $baseUrl, $neighbours);

echo '<a href="'.$pagination->first()->link().'">First</a>';
echo '<a href="'.$pagination->previous()->link().'">Previous</a>';
foreach ($pagination as $page) {
    if ($page->isActive()) {
        echo '<b>'.$page->number().'</b>';
    } else {
        echo '<a href="'.$page->link().'">'.$page->number().'</a>';
    }
}
echo '<a href="'.$pagination->next()->link().'">Next</a>';
echo '<a href="'.$pagination->last()->link().'">Last</a>';