PHP生成二维码 phpqrcode.php下载

生成二维码代码:

将在当前页面生成一个二维码图片显示在页面上:
[code lang=”php”]
include ‘phpqrcode.php’;
QRcode::png(‘http://shanmao.me’);
[/code]

将在当前文件夹下生成一个二维码图片(shanmaome.png)
[code lang=”php”]

include ‘phpqrcode.php’;
$value = ‘http://shanmao.me’;
$errorCorrectionLevel = ‘L’;//容错级别
$matrixPointSize = 10;//生成图片大小
//生成二维码图片
QRcode::png($value, ‘shanmaome.png’, $errorCorrectionLevel, $matrixPointSize, 2);
[/code]

点击下载二维码代码:

[code lang=”php”]
$url_format= $_GET[‘url’];
if($url_format){
include ‘phpqrcode.php’;
$errorCorrectionLevel = ‘L’;//容错级别
$matrixPointSize = 100;//生成图片大小
//生成二维码图片

if($_GET[‘down’]>0){//如果需要下载
$filename = "data/ewm/".$_GET[‘down’].’.png’;//图片路径
QRcode::png($url_format, $filename, $errorCorrectionLevel, $matrixPointSize, 2);
if(is_file($filename)){//开始下载
header("Content-Type: application/force-download");
header("Content-Disposition: attachment; filename=".basename($filename));
readfile($filename);
exit;
}else{
exit(‘二维码生成出错’);
}

}
}
[/code]

完整版:phpqrcode-2010100721_1.1.4

单文件:phpqrcode