PHP code example of hbgl / php-code-128-encoder

1. Go to this page and download the library: Download hbgl/php-code-128-encoder library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

hbgl / php-code-128-encoder example snippets




bgl\Barcode\Code128Encoder;

// Encode as Code 128.
$encoded = Code128Encoder::encode('ABC123456DEF');
assert ($encoded === 'ÌABCÇ,BXÈDEFqÎ');

// Only encode using Type A.
$encodedA = Code128Encoder::encode('ABC123456DEF', 'A');
assert ($encodedA === 'ËABC123456DEFLÎ');

// Only encode using Type B.
$encodedB = Code128Encoder::encode('AcC123456DeF', 'B');
assert ($encodedB === 'ÌAcC123456DeFSÎ');

// Only encode using Type C.
$encodedC = Code128Encoder::encode('123456', 'C');
assert ($encodedC === 'Í,BXLÎ');



bgl\Barcode\Code128Encoder;

$content = 'ABC123456DEF';
$encoded = Code128Encoder::encode($content);