CODE 11

CODE 11 barcode in PHP: character set, check characters, code example and SVG output

Eleven characters: the ten digits and the dash. S is the start and the stop character. One check character is appended for payloads up to ten characters, two above that.

Type Token

ItemValue
Type tokenCODE11
Enum caseBarcodeType::CODE11
FamilyLinear
StandardUSD-8
Class\Com\Tecnick\Barcode\Type\Linear\CodeOneOne

Input

ItemValue
Character set0-9 and -
Length1 to 30000 characters
Checkone check character, or two when the payload is longer than 10 characters
Extra parametersnone

Examples

Ten digits, one check character

<?php

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

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

echo $bobj->getInlineSvgCode();

CODE 11 barcode encoding 0123456789

Thirteen digits, two check characters

$bobj = $barcode->getBarcodeObj(
    type: 'CODE11',
    code: '0123456789012',
    width: -3,
    height: -30,
    color: 'black',
    padding: [0, 0, 0, 0],
)->setBackgroundColor('white');

CODE 11 barcode encoding 0123456789012

Errors

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

PayloadMessage
12AInvalid character: 65

See Also