PHP source code for generating images online using QR codes

Source: Internet
Author: User

PHP source code for generating images online using QR codes

QR Code is becoming more and more popular. Here we will introduce the QR Code generated by PHP at both ends, one using the QR Code API opened by Google, and the other using the php qr Code open-source library.

1. Use the Google Chart API to generate a QR code Image

Google Chart API is a powerful API. Generating a QR code is only a small function. Here only introduces the QR code part, if you want to know more functions, you can log on to the official website address: http://code.google.com/intl/zh-CN/apis/chart/

The Code is as follows:

  

$ UrlToEncode = "http://www.weste.net ";

GenerateQRfromGoogle ($ urlToEncode );

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

{

$ Url = urlencode ($ url );

Echo '';

}

?>

Generated QR code image:

2. Use php qr Code to generate a QR Code Image

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. Powerful and easy to use.

The demo code is as follows:

  

Include "./phpqrcode. php ";

$ Value = "http://www.weste.net ";

$ ErrorCorrectionLevel = "L ";

$ MatrixPointSize = "4 ";

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

Exit;

?>

Generated QR code image:

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.