PHP code example of komakino / luhn

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

    

komakino / luhn example snippets


use Komakino\Luhn\Luhn;

Luhn::validate('12345678'); // returns false
Luhn::validate('87654323'); // returns true

Luhn::calculate('1234567'); // returns 4
Luhn::calculate('8765432'); // returns 3

Luhn::appendCheckDigit('1234567'); // returns 12345674
Luhn::appendCheckDigit('8765432'); // returns 87654323