PHP generates barcodes

Source: Internet
Author: User

Before the array to do a merchant coupon function, need to use the barcode, so the data re-organized.

1. What is a barcode?

Baidu Encyclopedia definition: bar code (barcode) is the width of a number of black bars and blank, according to a certain coding rules, to express a set of information graphic identifier. A common barcode is a pattern of parallel lines of black strips (short strips) and white bars (short ones) that vary greatly in reflectivity. In daily life, bar code can be marked out of the goods producing countries, manufacturers, product names, production dates, book classification number, mail location, the type, date and many other information. Please refer to the Barcode encoding format for details

Printed coupons, merchants need to use the authenticator to read the barcode, to obtain its validity.

2. How do I generate barcodes?

  First find strong open source materials, download the Barcodegen.1d-php5.v5.0.1.zip version on barcode website, and then extract the files to the root directory of your Apache server.

  2.1 File Structure:

    

2.2 Specific Analysis

(1) Class folders are classes that have been packaged to generate barcodes, and only need to be called.

(2) index.php is an optional condition to generate barcode function, is the main program entrance, and the HTML folder is provided by the referenced code, code39.php refers to the default encoding format.

<?phpheader (' location:html/code39.php ');? >

When accessing http://localhost/barcodegen/index.php directly, the user experience can experience this feature, selecting any item and generating the corresponding barcode. You can use it as a module if you need to.

  

    

(3) test.php is another example of generating a hello barcode directly from the code.

When accessing http://localhost/barcodegen/test.php, the Hello.png picture is generated

    

View Code

3. Practical Application

For a general understanding of the above, we can re-integrate the code below, more convenient to use it.

  First create a new buildcode.php file, overwrite it according to the test.php file, and fetch the data from the requested file:

1. Barcode encoding Format

2. The data content required by the barcode

View Code

Then create a new test.html file and request data to buildcode.php

View Code

Last access to http://localhost/barcodegen/test.html or access http://localhost/barcodegen/buildcode.php?codebar=bcgcode39& Text=abc123, the browser directly generates a PNG-formatted barcode

  

where Codebar supports encoding formats that can be requested by the user:

/* ' Bcgcodabar ', ' BCGcode11 ', ' BCGcode39 ', ' bcgcode39extended ', ' BCGcode93 ', ' BCGcode128 ', ' BCGean8 ', ' BCGean13 ', ' Bcgisbn ', ' BCGi25 ', ' BCGs25 ', ' bcgmsi ', ' bcgupca ', ' bcgupce ', ' BCGupcext2 ', ' BCGupcext5 ', ' bcgpostnet ', ' bcgothercode ' * /

4. Verification

  How do we verify that the barcode is valid, that is, the ability to read the contents of the barcode.

First save the picture, and then visit the official website to provide the verification function, upload the image is ok!

    

Reprinted from: http://www.cnblogs.com/ForEvErNoME/archive/2012/04/21/2460944.html

PHP generates barcodes

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.