PHP生成QRCode二维码

<?php



//引入 phpqrcode 类库
//phpqrcode下载地址:https://github.com/t0k4rt/phpqrcode
require_once "phpqrcode/qrlib.php";



//第一种(缺省下在网页中生成二维码)
//调用QRCode类下的png静态方法
QRcode::png("this is a qrcode");



$content = "this is a qrcode";	//内容
$filename = time() . ".png";	//文件名
$level = QR_ECLEVEL_L;			//容错级别
$size = 10;						//尺寸
$padding = 3;					//边距

//第二种(自定义下在网页中生成二维码)
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%的数据码字
*/



?>