Simple php qr code generation instance

Source: Internet
Author: User

Php qr code generationThere are many ways to generate a QR Code by using APIs opened by google and the php QR Code library. This article focuses on using the php QR Code library to generate a QR Code.
1. Code package download address:
2. There are many examples in the downloaded compressed package. You can study it on your own. The following is a simple example:

The code is as follows: Copy code

Include "phpqrcode/phpqrcode. php ";
$ Data = 'http: // ';
$ ErrorCorrectionLevel = "L ";
$ MatrixPointSize = "4 ";
QRcode: png ($ data, false, $ errorCorrectionLevel, $ matrixPointSize );

Official method instance

The code is as follows: Copy code

<? Php
# Include one of the two files:
Qrlib. php for full version (also you have to provide all library files
Form package plus cache dir)

OR phpqrcode. php for merged version (only one file,
But slower and less accurate code because disabled cache
And quicker masking configured)
# Two sentences:
# Put qrlib. php together with other files: files and folders.
# Phpqrcode. php is a merged version. You only need to include this file, but the generated image is slow and inaccurate.
# The following two usage methods are provided:

# Create a QR code file
QRcode: png ('code data text', 'filename.png ');
// Creates file

# Generating images to the browser
QRcode: png ('Some othertext 1234 ');
// Creates code image and outputs it directly into browser

3. Some QR codes have images in the middle. In fact, you can copy the images to the generated QR code.

Use google to generate an open interface for QR code. The code is as follows:

The code is as follows: Copy code

* 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 data 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 ($ data, $ widhtHeight = '000000', $ EC_level = 'l', $ margin = '0 '){
$ Url = urlencode ($ data );
Echo ' ';

Call method

The code is as follows: Copy code

$ Data = 'copyright: /';
GenerateQRfromGoogle ($ data );

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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: and provide relevant evidence. A staff member will contact you within 5 working days.