PHP生成QRCode二维码

php生成QRCode二维码示例

<?php
//引入 phpqrcode 类库
//phpqrcode下载地址:https://github.com/t0k4rt/phpqrcode
//或从博客园下载:https://files.cnblogs.com/files/connect/phpqrcode-master.zip
require_once "phpqrcode/qrlib.php";

// 初始化二维码图片的参数
$content = "this is a qrcode";		//内容
$filename = time() . ".png";		//文件名
$level = QR_ECLEVEL_L;				//容错级别
$size = 10;							//尺寸
$padding = 3;						//边距

//第一种(缺省下在网页中生成二维码),调用QRCode类下的png静态方法
QRcode::png($content);

//第二种(自定义下在网页中生成二维码)
QRcode::png($content, false, $level, $size, $padding, true);

//第三种(自定义下将生成的二维码保存为图片文件)
QRcode::png($content, $filename, $level, $size, $padding, true);

/*容错级别
QR_ECLEVEL_L 为常量 0 约可纠错7%的数据码字
QR_ECLEVEL_M 为常量 1 约可纠错15%的数据码字
QR_ECLEVEL_Q 为常量 2 约可纠错25%的数据码字
QR_ECLEVEL_H 为常量 3 约可纠错30%的数据码字
*/
?>

 

phpqrcode类库下载

 

本文链接:https://www.cnblogs.com/connect/p/php-qrcode-image.html

 

posted @ 2017-08-11 11:26  varlemon  阅读(349)  评论(0编辑  收藏  举报