PHP二维码扩展库 exqrcode
一个php扩展,调用libqren库,生成二维码图片,可以生成一般文本、url、短信息、电话、电子名片等。
安装环境:linux,php5.3
外部库支持libqrencode,libpng
使用方法:
$instance = new ExQrcode();
//ExQrcode::QRLEVEL_L
//ExQrcode::QRLEVEL_M
//ExQrcode::QRLEVEL_Q
//ExQrcode::QRLEVEL_H
$instance->setLevel(ExQrcode::QRLEVEL_H);
$instance->setSize(7);
//$instance->setDpi(72);
$instance->encodeGeneral("hello world");
var_dump($instance->writeToFile("/tmp/qrgeneral.png"));
$instance->encodeUrl("http://www.baidu.com");
var_dump($instance->writeToFile("/tmp/qrurl.png"));
$arr = array("N" => "name","TEL" => "13900000000","EMAIL" => "email"
, "ADDR" => "address" ,"URL" => "http://www.helloworld.com");
$instance->encodeMECard($arr);
var_dump($instance->writeToFile("/tmp/qrmecard.png"));
$instance->encodePhone("13900000000");
var_dump($instance->writeToFile("/tmp/qrphone.png"));
$instance->encodeSMS("message subject","message content");
var_dump($instance->writeToFile("/tmp/qrsms.png"));