In web applications like an online-ticketing system, encoding the purchase reference number as barcodes on the ticket print or voucher can be quite useful in helping over-the-counter staff to quickly handle processes such as guest check-in using a barcode scanner.
There are many kinds of barcode formats out there to cater the types or amount of data you are trying to encode. However if you are just starting out for a bit of familiarization, generating 1D barcodes with PHP couldn’t be simpler with the free (for non-commercial use) PHP Barcode Generator class.
Extract the ZIP and use the following line to generate a barcode in a Code 39 barcode format encoding the string A1B2C3D3.
<div> <img src="html/image.php?code=code39&o=1&dpi=72&t=80&r=1&rot=0&text=A1B2C3D3&f1=Arial.ttf&f2=10&a1=&a2=&a3=" alt="Barcode" /> </div>
Some key parameters:
Parameters | Description |
---|---|
code | The barcode format. Most of the standard 1D formats are supported such as Code 93 (code93), Code 128 (code128), UPC (upca) and EAN 8 (ean8). |
o | The output image format; PNG (1), JPEG (2) or GIF (3) |
t | The thickness or height |
rot | The rotation angle; 0, 90, 180 or 270 |
text | The data to encode. Code 39 only supports uppercase letters and numeric digits. |
f2 | The font size of the label |
For a more detailed explanation of each parameters and configurations, please refer to the barcode generator GUI tool bundled in the ZIP archive.
Have a nice day.