PHP generates QR code implementation code_PHP tutorial

WBOY
Release: 2016-07-20 11:11:22
Original
1197 people have browsed it

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 you include qrlib.php, you need to put it 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:

The code is as follows
 代码如下 复制代码

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

Copy code


include('./phpqrcode/phpqrcode.php');

// QR code data
代码如下 复制代码
$col[0] = ImageColorAllocate($base_image,255,255,255);
$col[1] = ImageColorAllocate($base_image,0,0,0);
$data = 'http://gz.altmi.com';

// Generated File name

$filename = $errorCorrectionLevel.'|'.$matrixPointSize.'.png';

// Error correction level: L, M, Q, H
$errorCorrectionLevel = 'L';

// Point size: 1 to 10
代码如下 复制代码

$urlToEncode="http://gz.altmi.com";
generateQRfromGoogle($urlToEncode);
function generateQRfromGoogle($chl,$widhtHeight ='150',$EC_level='L',$margin='0')
{
$url = urlencode($url);
echo 'QR code';
}

$matrixPointSize = 4; QRcode::png($data, $filename, $errorCorrectionLevel, $matrixPointSize, 2);?> ;
# Create a QR code file

QRcode::png('code data text', 'filename.png');

// creates file # Generate Image to browserQRcode::png('some othertext 1234'); // creates code image and outputs it directly into browser If you want to generate colored ones, you need to do it yourselfModify the color setting part of the code in the image method of the QRimage class in phpqrcode.php. The code of version 1.1.4 is in lines 987 and 988, one foreground color, one Background color:
The code is as follows Copy code
$col[0] = ImageColorAllocate($base_image,255,255,255);$col[1] = ImageColorAllocate($base_image,0,0,0); You canuse google open api to generate
The code is as follows Copy code
$urlToEncode="http://gz.altmi.com"; generateQRfromGoogle($urlToEncode) ; function generateQRfromGoogle($chl,$widhtHeight ='150',$EC_level='L',$margin='0') { $url = urlencode($url); echo 'QR code'; } http://www.bkjia.com/PHPjc/444661.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/444661.htmlTechArticleQR code is a type of two-dimensional barcode that can encode information such as website addresses, text, photos, etc. The algorithm is compiled into a square barcode pattern, and mobile phone users can use the camera...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template