PHP code example of metro-markets / gtin-validator
1. Go to this page and download the library: Download metro-markets/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/ */
metro-markets / gtin-validator example snippets
use Real\Validator\Gtin;
// create a valid GTIN
$value = '4006381333931';
$gtin = Gtin\Factory::create($value);
// handle errors
$value = 'any invalid value';
try {
$gtin = Gtin\Factory::create($value);
} catch (Gtin\NonNormalizable $e) {
// ...
}