Barcode generator for PHP logo

Whilst fiddling around with QR Codes, I came across this Bar-code generator for PHP.

Minimum requirements:

  • PHP 5
  • GD2 Extension

Here is my code for a basic implementation (adapted from the manual which has errors):


// The arguments are R, G, and B for color.
$colorBack = new BCGColor(255, 255, 255);
$code = new BCGcode128(); // Or another class name from the manual
$code->parse('BARCODE'); // Text
$image_name = 'mybc.png';
$drawing = new BCGDrawing($image_name, $colorBack);

header('Content-Type: image/png');

echo '<img src="'.$image_name.'" />';

By foxbeefly

PHP / MySQL Developer. HTML, CSS and some JavaScript.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.