本文已参与「新人创作礼」活动,一起开启掘金创作之路。
简述二维码 二维码 最先在1920 单据邮政自动分检法 八十年代引入国内 2000内制定国标
二维码分类
- 1.线性堆叠式二维码
- 2.矩阵二维码
二维码优缺点:
- 1.信息容量大
- 2.编码范围广
- 3.容错能力强
- 4.译码可靠性高
- 5.可引入加密措施
- 6.成本低 易制作
二维码缺点:
-
1.容易成为不良链接渠道
-
2.信息泄密
-
·目前流行三大国际标准: 1.PDF417 不支持中文 2.DM 专利未公开 需要支付专利费用 3.QR Code 专利公开 支持中文 (对比优势:识别速度快 数据密度大 占用空间小)
QR code二维码:
- 研发背景:日本 1996年 Quick Response Code
- 支持300字符
纠错能力: L级:约7%的数据码字 M级:约15%的数据码字 Q级:约25%的数据码字 H级:约30%的数据码字
**PHP生成QRcode二维码**
要求:php有GD拓展 phpinfo可看到
phprqcode官网下载对应的拓展压缩包
生成二维码:
include "phpqrcode/qrlib.php";
QRcode::png('abc','images/'.time().'.gif',QR_ECLEVEL_L,10,1,true);
//文本内容 文件名 二维码级别 尺寸 距离 保存打印
//png($text, $outfile = false, $level = QR_ECLEVEL_L, $size = 3, $margin = 4, $saveandprint=false)
生成电子名片二维码:
*
* N 姓氏
* FN 名字
* ORG 公司地址
* TEL;WORK;VOICE 工作单位电话
* TEL;HOME;VOICE 家里电话
* TEL;TYPE=cell 移动电话
* ADR;HOME 家庭住址
* EMAIL 邮箱
* URL 网站
*/
include 'phpqrcode/qrlib.php';
$content = 'BEGIN:VCARD'."\n";
$content .= 'VERSION:2.1'."\n";
$content .= 'N:赵'."\n";
$content .= 'FN:兴路'."\n";
$content .= 'TEL;WORK;VOICE:022-888888'."\n";
$content .= 'TEL;HOME;VOICE:022-666666'."\n";
$content .= 'TEL;TYPE=cell:15502293820'."\n";
$content .= 'EMAIL:461953216@qq.com'."\n";
$content .= 'URL:www.xinglu.com'."\n";
$content .= 'ADR;HOME:天津西青区'."\n";
$content .= 'ORG:天铁科贸大厦'."\n";
$content .= 'END:VCARD'."\n";
QRcode::png($content);
Jquery生成QRcode二维码 要求: jquery.min.js jquery.qrcode.min.js
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js"></script>
<script src="jquery-qrcode-master/jquery.qrcode.min.js"></script>
<title>QR Code</title>
</head>
<body>
<div id="qrcode"></div>
<script>
//这里需要在DOM元素的后面
$("#qrcode").qrcode('this plugin is great')
$('#qrcode').qrcode({width: 64,height: 64,text: "size doesn't matter"})
</script>
</body>
</html>
识别二维码 需要准备: ImageMagick 对图片 -> 读写 旋转 变形 下载:imagemagick.org/script/down… zbar 从图片读取信息 下载:zbar.sourceforge.net/download.ht… php-zbarcode php组件 下载:github.com/mkoppanen/p…
配置php-zbarcode 详情请参照 php拓展的安装:blog.csdn.net/qq_17040587…
require_once('vendor/autoload.php');
$ZbarDecoder = new RobbieP\ZbarQrdecoder\ZbarDecoder();
# Optionally change the path of the zbarimg executable if you need to (default: /usr/bin)
//$ZbarDecoder->setPath('/usr/local/bin');
# Decode the image
$result = $ZbarDecoder->make('./abc.jpg');
echo $result; // Outputs the decoded text
echo $result->format; // Outputs the barcode's format
echo $result->code; // 200 if it decoded a barcode OR 400 if it couldn't find a barcode
- 我正在参与掘金技术社区创作者签约计划招募活动,点击链接报名投稿。