PHP code example of nfephp-org / sped-gtin
1. Go to this page and download the library: Download nfephp-org/sped-gtin 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/ */
nfephp-org / sped-gtin example snippets
use NFePHP\Gtin\Gtin;
try {
$gtin = new Gtin('78935761');
$region = $gtin->region;
$prefix = $gtin->prefix;
$digitoVerificador = $gtin->checkDigit;
if ($gtin->isValid()) {
echo "Valido";
}
} catch (\Exception $e) {
echo $e->getMessage();
}
use NFePHP\Gtin\Gtin;
try {
$gtin = Gtin::check('78935761');
$region = $gtin->region;
$prefix = $gtin->prefix;
$digitoVerificador = $gtin->checkDigit;
if ($gtin->isValid()) {
echo "Válido";
}
} catch (\Exception $e) {
echo $e->getMessage();
}
use NFePHP\Gtin\Gtin;
$gtin = "78935761";
try {
if (Gtin::check($gtin)->isValid()) {
echo "Válido";
}
} catch (\Exception $e) {
echo $e->getMessage();
}