PHP code example of richarddobron / ean-utils

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

    

richarddobron / ean-utils example snippets


use dobron\EanUtils\Ean13Generator;
use dobron\EanUtils\Ean8Generator;

$ean13 = new Ean13Generator();

$ean13->generate('1234567', '500'); // 5000012345675
$ean13->generate('1234567'); // 0000012345670

$ean8 = new Ean8Generator();

$ean8->generate('123', '212'); // 21201233
$ean8->generate('123'); // 00001236

use dobron\EanUtils\EanValidator;

$eanValidator = new EanValidator();

$eanValidator->validate('5000012345675'); // true

$eanValidator->validate('1234567'); // false

$eanValidator->validate('ABCDEFGH'); // false