PHP code example of pmigut / gtin-validator

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

    

pmigut / gtin-validator example snippets




use Pmigut\GtinValidator\Gtin8;

var_dump(Gtin8::isValid('12312312'));
// Output: false



declare(strict_types=1);

use Pmigut\GtinValidator\Gtin8;

var_dump(Gtin8::isValid(12312312));
// Output: PHP Fatal error:  Uncaught TypeError: Argument 1 passed to
// Pmigut\GtinValidator\Gtin8::isValid() must be of the type string, integer given



use Pmigut\GtinValidator\Gtin13;

var_dump(Gtin13::isValid('0000906332847'));
// Output: true

var_dump(Gtin13::isValid('906332847'));
// Output: false