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.
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: