二维码的用处俺也就不说了,看一下用PHP生成的二维码吧。

利用谷歌提供的API 生成二维码,如今非常多国外站点都提供了这类API

看下代码吧《=======================》

<?php
$urlToEncode="http://gz.altmi.com";
generateQRfromGoogle($urlToEncode);
function generateQRfromGoogle($chl,$widhtHeight ='150',$EC_level='L',$margin='0')
{
$url = urlencode($url);
echo '<img src="http://chart.apis.google.com/chart? chs='.$widhtHeight.'x'.$widhtHeight.'&cht=qr&chld='.$EC_level.'|'.$margin.'&chl='.$chl.'" alt="QR code"
widhtHeight="'.$size.'" widhtHeight="'.$size.'"/>';
}
?>

上面的方式特别的简便,可是假设人家站点不提供这样的API 了,我们岂不是要歇菜了么?还是用我们的PHP 类库吧

php类库PHP QR Code

地址:http://phpqrcode.sourceforge.net/

下载:http://sourceforge.net/projects/phpqrcode/

实例:

<?

php
include('./phpqrcode/phpqrcode.php');
// 二维码数据
$data = 'http://gz.altmi.com';
// 生成的文件名称
$filename = $errorCorrectionLevel.'|'.$matrixPointSize.'.png';
// 纠错级别:L、M、Q、H
$errorCorrectionLevel = 'L';
// 点的大小:1到10
$matrixPointSize = 4;
QRcode::png($data, $filename, $errorCorrectionLevel, $matrixPointSize, 2);
?>
官方给出的用例:
<?php
# include这两个文件之中的一个:
/*
qrlib.php for full version (also you have to provide all library files
form package plus cache dir) OR phpqrcode.php for merged version (only one file,
but slower and less accurate code because disabled cache
and quicker masking configured)
*/
# 两句话解释:
# 包括qrlib.php的话须要同其他文件放到一起:文件、目录。
# phpqrcode.php是合并后版本号。仅仅须要包括这个文件,但生成的图片速度慢并且不太准确
# 下面给出两种使用方法: # 创建一个二维码文件
QRcode::png('code data text', 'filename.png');
// creates file # 生成图片到浏览器
QRcode::png('some othertext 1234');
// creates code image and outputs it directly into browser



嘿嘿。能够自己试一试 玩玩。德玛上单。不给就送哦。

最新文章

  1. ZeroMQ接口函数之 :zmq_msg_copy - 把一个消息的内容复制到另一个消息中
  2. 使用pip安装 cx_Oracle 模块
  3. Sprint2(12.6)
  4. CSS强制性换行word-break与word-wrap的使用
  5. Compute Mean Value of Train and Test Dataset of Caltech-256 dataset in matlab code
  6. ASP.NET 数据库页面访问简单工具
  7. 【Node】SuperAgent
  8. Column store index 列数据如何匹配成行数据?
  9. 12C dbca silent
  10. DevOps之网络
  11. CentOS7──xxx is not in the sudoers file
  12. 利用谷歌网站的翻译网站,实现谷歌翻译api
  13. c/c++链队列
  14. A+B Problem(再升级)
  15. [LintCode] Linked List Cycle(带环链表)
  16. 在centos7 ubuntu15.04 上通过bosh-lite 搭建单机环境cloudfoundry
  17. JavaScript学习总结(六)——JavaScript判断数据类型总结
  18. 转-Vue.js2.0从入门到放弃---入门实例(一)
  19. 在Qt中如何使用QtDesigner创建的UI文件(一) (转)
  20. c# 委托与事件的区别

热门文章

  1. 部署微信定位精灵APK到Genymotion
  2. 【TYVJ1936】【Clover杯NOIP模拟赛IV】太空战队
  3. 关于H5优化的一些问题
  4. [Offer收割]编程练习赛40
  5. Matplotlib库常用函数大全
  6. hdu2686/hdu3376 最小费用流最大流 拆点
  7. ubuntu下安装 nginx + php + memcached + mariadb
  8. 杭电 2035 人见人爱A^B【快速幂取模】
  9. Python 数据清洗--处理Nan
  10. 记一次IOS对 JS的支持问题