Skip to content

Latest commit

 

History

History
43 lines (33 loc) · 1.06 KB

README.md

File metadata and controls

43 lines (33 loc) · 1.06 KB

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