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: