php
php

PHP QR Code类库生成二维码

由于二维码被广泛使用,现在在web开发中不得不经常生成各种二维码。可以利用PHP类库“PHP QR Code”来生成一种常见的二维码——QR码。

类库下载URL: http://phpqrcode.sourceforge.net/

qrlib.php 是完整版,官方的调用实例:

QRcode::png('code data text', 'filename.png'); // creates file 

QRcode::png('some othertext 1234'); // creates code image and outputs it directly into browser

phpqrcode.php 是合并版,只有一个文件,但生成速度较慢且不太准确。使用方法:

//
include "phpqrcode/phpqrcode.php; 

$data=“http://www.hiheng.com”;  //二维码数据

$filename = $errorCorrectionLevel.'|'.$matrixPointSize.'.png'; //生成的文件名

$errorCorrectionLevel = 'L';   //纠错级别 L | M | Q | H
$matrixPointSize = 4;    //每个黑点的像素 1~10
QRcode::png($data,$filename,$errorCorrectionLevel,$matrixPointSize);
//