Two php qr code generation methods

Source: Internet
Author: User

PHP generates a QR code. I personally think there are two most common types: 1. use the google api to generate, 2. use php qr Code generation. The QR Code generated in both methods is clear and effective. The following describes how these two methods are implemented.

I. PHP uses google api to generate a QR code online:

Let's not talk about this API. You can go to Google's official website for query. I believe you are concerned with the specific code, as shown below:

1

2 $ urlToEncode = "http://www.csdn.net"; // URL of the QR code to be generated

3 generateQRfromGoogle ($ urlToEncode );

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

5 {

6 $ url = urlencode ($ url );

7 echo'


'; // The Google API. If the API fails, you can query the latest API on the Google website.

8}

9?>

Ii. Use php qr Code to generate a QR Code:

1

2 include "phpqrcode. php"; // introduce the php qr Library File

3 $ value = "http://www.csdn.net ";

4 $ errorCorrectionLevel = "L ";

5 $ matrixPointSize = "4 ";

6 QRcode: png ($ value, false, $ errorCorrectionLevel, $ matrixPointSize );

7 exit;

8?>

Php qr Code is an open-source php QR Code open-source library. It is based on the libqrencode C library and provides API Code to create QR Code images. It supports png and jpg formats. If you do not have this library, you can download it here: php qr Code generation Library

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.