QR code is a type of two-dimensional barcode. It can compile website addresses, text, photos and other information into a square barcode pattern through corresponding encoding algorithms. Mobile phone users can re-decode the relevant information and view the content through the camera and decoding software.
php class library PHP QR Code
# Two sentence explanation:
# If it contains qrlib.php, it needs to be placed together with other files: files and folders.
# phpqrcode.php is the merged version, you only need to include this file, but the generated image is slow and inaccurate
# Two usages are given below:
<?php include('./phpqrcode/phpqrcode.php'); // 二维码数据 $data = 'http://gz.altmi.com'; // 生成的文件名 $filename = $errorCorrectionLevel.'|'.$matrixPointSize.'.png'; // 纠错级别:L、M、Q、H $errorCorrectionLevel = 'L'; // 点的大小:1到10 $matrixPointSize = 4; QRcode::png($data, $filename, $errorCorrectionLevel, $matrixPointSize, 2); ?> # 创建一个二维码文件 QRcode::png('code data text', 'filename.png'); // creates file # 生成图片到浏览器 QRcode::png('some othertext 1234'); // creates code image and outputs it directly into browser
If you generate colorful ones, you need to do it yourself
Modify phpqrcode. The code for the color setting part of the image method of the QRimage class in php. The code for version 1.1.4 is at lines 987 and 988. One foreground color and one background color:
$col[0] = ImageColorAllocate($base_image,255,255,255); $col[1] = ImageColorAllocate($base_image,0,0,0);
Just
generate using Google’s open api
$urlToEncode="http://gz.altmi.com"; generateQRfromGoogle($urlToEncode); function generateQRfromGoogle($chl,$widhtHeight ='150',$EC_level='L',$margin='0') { $url = urlencode($url); echo '<img src="http://chart.apis.google.com/chart?chs='.$widhtHeight.'x'.$widhtHeight.'&cht=qr&chld='.$EC_level.'|'.$margin.'&chl='.$chl.'" alt="QR code" widhtHeight="'.$size.'" widhtHeight="'.$size.'"/>'; }