Bar code checker and type identifier

With this class you can easily check if an EAN / JAN / UPC / GTIN-8 / GTIN-14 code is correct.
It will return the bar code if it is a correct bar code and will return FALSE if not.
The code can also return the type of code.

About Bar code checker

link: http://www.phpclasses.org/package/8560-PHP-Detect-type-and-check-EAN-and-UPC-barcodes.html
author: Ferry Bouwhuis
version: 1.0.1
LastChange: 2014-04-13

Example's

Check if bar code is correct:
clsLibGTIN::GTINCheck(4960759124036) will return: 4960759124036
clsLibGTIN::GTINCheck(1234567890123) will return: FALSE
clsLibGTIN::GTINCheck(0018208253265) will return: 0018208253265

Check if bar code is correct and return GTIN-14 format:
clsLibGTIN::GTINCheck(4960759124036, TRUE) will return: 4960759124036
clsLibGTIN::GTINCheck(1234567890123, TRUE) will return: FALSE
clsLibGTIN::GTINCheck(0018208253265, TRUE) will return: 0018208253265

Check type by adding optional parameter:
clsLibGTIN::GTINCheck(4960759124036,FALSE,1) will return: EAN
clsLibGTIN::GTINCheck(1234567890123,FALSE,1) will return: FALSE
clsLibGTIN::GTINCheck(0018208253265,FALSE,1) will return: UPC

Class can also check if the last digit of a code is correct.
clsLibGTIN::GTINCheckDigit(0018208253265) will return: TRUE
clsLibGTIN::GTINCheckDigit(1234567890123) will return: FALSE

Usage:

Add the class file (clsLibGTIN.php) to your project
Add the following line somewhere in your script:
require_once(clsLibGTIN.php);
Thats all you are ready to go and use this simple but usefull class.
You can call the function STATIC:

Correct ussage:
clsLibGTIN::GTINCheck(4960759124036)

Incorrect ussage:
$objEAN = new clsLibGTIN();
$objEAN->EanCheck(4960759124036);

Test it your self

You can test it yourself here: example.php

Also known as:

The above codes are also known as Global Trade Item Number (GTIN) develeped by GS1
The New official name's for the GTIN numbers are:

Name Former name(s)
GTIN-14
GTIN-13 EAN·UCC-13, JAN, EAN-13, CIP
GTIN-12 EAN·UCC-12, UCC-12, UPC
GTIN-8 EAN·UCC-8, EAN-8


GTIN: Global Trade Item Number EAN: European Article Number
JAN: Japanese Article Number
UPC: Universal Product Code