2.php类库PHP QR Code

PHP QR Code is open source (LGPL) library for generating QR Code/
2-dimensional barcod">

Home  >  Article  >  Backend Development  >  Several ways to generate QR codes in PHP and their usage examples_PHP tutorial

Several ways to generate QR codes in PHP and their usage examples_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:09:40961browse

1.google开放api

复制代码 代码如下:

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

Several ways to generate QR codes in PHP and their usage examples_PHP tutorial 
2.php类库PHP QR Code

PHP QR Code is open source (LGPL) library for generating QR Code,
2-dimensional barcode. Based on libqrencode C library,
provides API for creating QR Code barcode images (PNG, JPEG thanks to GD2).
Implemented purely in PHP, with no external dependencies (except GD2 if needed).
地址:http://phpqrcode.sourceforge.net/
下载:http://sourceforge.net/projects/phpqrcode/
实例:
复制代码 代码如下:

include "./phpqrcode/phpqrcode.php";
$value="http://www.weste.net";
$errorCorrectionLevel = "L";
$matrixPointSize = "4";
QRcode::png($value, false, $errorCorrectionLevel, $matrixPointSize);
exit;
?>

主页地址:http://phpqrcode.sourceforge.net/,站点里能直接下载源码,下载后解压到web目录,通过网页访问,就可以看到demo演示。
Several ways to generate QR codes in PHP and their usage examples_PHP tutorial 
Data表示要记录的数据,如果是存储utf-8编码的中文,最多984个。
ECC表示纠错级别, 纠错级别越高,生成图片会越大。
L水平 7%的字码可被修正
M水平 15%的字码可被修正
Q水平 25%的字码可被修正
H水平 30%的字码可被修正Size表示图片每个黑点的像素。
代码的调用范例:
复制代码 代码如下:

include "qrlib.php";
QRcode::png($data, $filename, $errorCorrectionLevel, $matrixPointSize, $margin);
/*
$data 数据
$filename 保存的图片名称
$errorCorrectionLevel 错误处理级别
$matrixPointSize 每个黑点的像素
$margin 图片外围的白色边框像素
*/

QR码详细原理可以参考QR维基百科,中文版介绍比较少,英文版介绍很全面,推荐看英文版的。
另外,现在QR码已经有彩色版的了,还可以嵌入个性图片,我在这方面做了些研究, 如果有兴趣,可以和我联系交流。我的联系邮箱参考网站右边栏目。

3.libqrencode
地址:http://fukuchi.org/works/qrencode/index.en.html
php支持请参考:http://hirokawa.netflowers.jp/entry/4900/

4.QRcode Perl CGI & PHP scripts
地址:http://www.swetake.com/qr/qr_cgi.html

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/327232.htmlTechArticle1.google开放api 复制代码 代码如下: $urlToEncode="http://bbs.lewanchina.com"; generateQRfromGoogle($urlToEncode); function generateQRfromGoogle($chl,$widhtHeight ='150',$EC...
Statement:
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