PHP code example of anstag / pager

1. Go to this page and download the library: Download anstag/pager 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/ */

    

anstag / pager example snippets

 php
$obj = new Anstag\Pager\DirPager(
    new Anstag\Pager\PagesList(),
    'photos',
    3,
    2
);

echo "<pre>";
print_r($obj->getItems());
echo "</pre>";

echo "<p>$obj</p>";
 php
$obj = new Anstag\Pager\FilePager(
    new Anstag\Pager\ItemsRange(),
    'largetextfile.txt'
);
    
echo "<pre>";
print_r($obj->getItems());
echo "</pre>";

echo "<p>$obj</p>";
 php
try {
    $pdo = new PDO(
        'mysql:host=localhost;dbname=test',
        'root',
        '',
        [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]
    );
    
    $obj = new Anstag\Pager\PdoPager(
        new Anstag\Pager\ItemsRange(),
        $pdo,
        'table_name'
    );
    
    echo "<pre>";
    print_r($obj->getItems());
    echo "</pre>";
    
    echo "<p>$obj</p>";
} catch (PDOException $e) {
    echo "Can't connect to database";
}