PHP code example of tankfairies / luhn

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

    

tankfairies / luhn example snippets


use Tankfairies\Luhn\Luhn;

$luhn = new Luhn(new SimpleNum());
$luhn->setTemplate('USR-####-####');

$token = $luhn->generate();

use Tankfairies\Luhn\Luhn;

$luhn = new Luhn(new SimpleAlnum());
$luhn->setTemplate('USR-####-####');

$token = $luhn->generate();

use Tankfairies\Luhn\Luhn;

$luhn = new Luhn();
$luhn->validate('USR-f36x-x79n9');