Php qr code generation method

Source: Internet
Author: User
Welcome to the Linux community forum and interact with 2 million technical staff. 1. Use google open APIs to complete [php] $ urlToEncodename: Liu xinming, phone: 18792448443; generateQRfromGoogle ($ urlToEncode ); *** googleapi QR code generation [QRcode can store up to 4296 letter and digit types

Welcome to the Linux community forum and interact with 2 million technical staff> 1. Use google open API to complete [php] $ urlToEncode = "name: Liu xinming, phone: 18792448443 "; generateQRfromGoogle ($ urlToEncode);/*** generate a QR code using google api [QRcode can store up to 4296 letters and numbers

Welcome to the Linux community forum and interact with 2 million technicians>

1. Use google to open APIs

[Php]

$ UrlToEncode = "name: Liu xinming, phone: 18792448443 ";

GenerateQRfromGoogle ($ urlToEncode );

/**

* Google api QR code generation [QRcode can store any text of a maximum of 4296 letters/numbers. For details, see the QR code data format]

* @ Param string $ information contained in the chlorophyll QR code, which can be numbers, characters, binary information, and Chinese characters. The data type cannot be mixed and must pass through the UTF-8 URL-encoded. If the information to be passed exceeds 2 K bytes, use the POST Method

* @ Param int $ widhtHeight: set the size of the generated QR code

* @ Param string $ EC_level: the error correction level is optional. The QR code supports four levels of error correction, which is used to restore lost, read, fuzzy, and data.

* L-Default: 7% of lost data can be identified.

* M-identifies 15% of data loss

* Q-identifies 25% of data loss

* H-identifies 30% of data loss

* @ Param int $ the distance between the QR code generated by margin and the image border

*/

Function generateQRfromGoogle ($ chlorophyll, $ widhtHeight = '000000', $ EC_level = 'l', $ margin = '0 ')

{

$ Chlorophyll = urlencode ($ chlorophyll );

Echo '';

}

For more details, see baidu Library: wenku. baidu./view/b2a6ffc60c22590102029dae.html

2. php QR Code library

Php qr Code is open source (LGPL) library for generating QR Code,

2-dimen1_barcode. Based on libqrencode C library,

Provides API for creating QR Code barcode images (PNG, JPEG thanks to GD2 ).

Implemented purely in PHP, with no external dependencies (using t GD2 if needed ).

PS: due to the time relationship, I only tested the Open API of google. Others can be tested by themselves.

========================================================== ========================================== ======================================

A two-dimensional bar code (2-dimen1_bar code) records data in a certain area of the Plane Based on a specific geometric pattern.

Commonly used Code systems include Data Matrix, Maxi Code, Aztec, QR Code, response Code, limit 417, Ultracode, Code 49, and Code 16K.

①: Stacked/row-arranged two-dimensional bar codes, such as Code 16 K, Code 49, and Code 417 (such ).

②: Matrix qr code is the most popular one.

The two-dimensional code stores a larger amount of data. It can contain numbers, characters, Chinese text, and other mixed content. It has a certain degree of fault tolerance (it can be read normally after some damages). It has a high space utilization rate.

③: Introduction to QR CODE

For example, the basic structure of a qrcode, where:

Location Detection Image, Location Detection Image separator, and positioning image: used to locate the QR code. For each QR code, the location is fixed, but the size and specifications may vary;

Calibration image: the specification is determined, and the quantity and position of the correction image are also determined;

Format information: indicates the error correction level for modifying the QR code, which can be L, M, Q, and H;

Version information: the type of the QR code. There are 40 types of matrix (generally black and white), from 21x21 (version 1 ), to 177x177 (version 40), each version adds four modules to each side of the previous version.

Data and Error Correction Code: the information of the actually saved QR code, and the error code (used to correct the error caused by damage to the QR code ).

Brief Encoding Process:

1. data analysis: determines the encoding character type and converts it to a symbolic character based on the corresponding character set. If an error correction level is selected, the higher the error correction level, the smaller the actual data capacity.

2. Data Encoding: converts a data character into a bitstream. Each 8-bit code word represents a code word sequence of data. In fact, the data content of the QR code is known as the data code sequence.

[1] [2]

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.