EAN-8

EAN-8 barcode in PHP: 8 digit input, check digit, code example and SVG output

EAN-8 exists for packages with no room for the full thirteen digits. The number is allocated separately rather than derived from the EAN-13 of the same product, so the two are unrelated. Unlike EAN-13 and the UPC pair, EAN-8 takes no add-on symbol.

Type Token

ItemValue
Type tokenEAN8
Enum caseBarcodeType::EAN8
FamilyLinear
StandardISO/IEC 15420, GS1 General Specifications
Class\Com\Tecnick\Barcode\Type\Linear\EanEight

Input

ItemValue
Character setdigits
Length7 digits, or 8 with a valid check digit
Checkmodulo 10, appended when the payload is 7 digits and verified when it is 8
Extra parametersnone

Examples

A short article number

<?php

require_once __DIR__ . '/vendor/autoload.php';

$barcode = new \Com\Tecnick\Barcode\Barcode();
$bobj = $barcode->getBarcodeObj(
    type: 'EAN8',
    code: '1234567',
    width: -3,
    height: -30,
    color: 'black',
    padding: [0, 0, 0, 0],
)->setBackgroundColor('white');

echo $bobj->getInlineSvgCode();

EAN-8 barcode encoding 1234567

Errors

These payloads raise \Com\Tecnick\Barcode\Exception:

PayloadMessage
123456AInput code must be a number
12345670+12EAN8 admits no add-on symbol

See Also