Skip to content

janwas/php-gtin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

php-gtin

Validate and categorize a GTIN = Global Trade Item Number

A PHP class for:

  • validating if the GTIN is valid

  • retrieving the type of the GTIN:

    • EAN-8
    • UPC
    • EAN-13
    • EAN-14
  • retrieving the subtype of the GTIN:

    • COMPANY_RESTRICTED
    • COUPON
    • FUTURE (not valid)
    • GID
    • ISBN
    • ISSN
    • REGION_RESTRICTED
  • returning the GTIN in the right format

The requirements are based on version 20.0 of the GS1 General Specifications, see paragraph 1.4.

usage

<?php
  include_once('GtinValidator.php');
  
  echo('<html>');
  $code = '0417953007527';
  
  $gtin = new gtinValidator($code);
  echo 'valid:' . $gtin->isValid() . ', gtin:' . $gtin->getGtin() . ', type:' . $gtin->getType() . ', subtype:' . $gtin->getSubType();
  
  echo('</html>');
?>

credits

About

validate and categorize a GTIN

Topics

Resources

License

Stars

Watchers

Forks

Languages