• php生成二维码的几种方式


    一些php生成二维码的方式:
    1.google开放api;
    2.php类库PHP QR Code;
    3.libqrencode;
    4.QRcode Perl CGI & PHP scripts
    1.google开放api 
    $urlToEncode="http://www.jbxue.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.'"/>'; 
    2.php类库PHP QR Code 
    PHP QR Code is open source (LGPL) library for generating QR Code, 
    2-dimensional barcode. Based on libqrencode C library, 
    provides API for creating QR Code barcode images (PNG, JPEG thanks to GD2). 
    Implemented purely in PHP, with no external dependencies (except GD2 if needed). 
    地址:http://phpqrcode.sourceforge.net/ 
    下载:http://sourceforge.net/projects/phpqrcode/ 
    实例: 
    <? 
    include "./phpqrcode/phpqrcode.php"; 
    $value="http://www.jbxue.com"; 
    $errorCorrectionLevel = "L"; 
    $matrixPointSize = "4"; 
    QRcode::png($valuefalse$errorCorrectionLevel$matrixPointSize); 
    exit
    ?> 
    主页地址:http://phpqrcode.sourceforge.net/,站点里能直接下载源码,下载后解压到web目录,通过网页访问,就可以看到demo演示。 
     
    Data表示要记录的数据,如果是存储utf-8编码的中文,最多984个。 
    ECC表示纠错级别, 纠错级别越高,生成图片会越大。 
    L水平 7%的字码可被修正 
    M水平 15%的字码可被修正 
    Q水平 25%的字码可被修正 
    H水平 30%的字码可被修正Size表示图片每个黑点的像素。 
    调用范例: 
    include "qrlib.php"; 
    QRcode::png($data$filename$errorCorrectionLevel$matrixPointSize$margin); 
    /* 
    $data 数据 
    $filename 保存的图片名称 
    $errorCorrectionLevel 错误处理级别 
    $matrixPointSize 每个黑点的像素 
    $margin 图片外围的白色边框像素 
    */ 
    QR码详细原理可以参考QR维基百科,中文版介绍比较少,英文版介绍很全面,推荐看英文版的。 
    另外,现在QR码已经有彩色版的了,还可以嵌入个性图片。 
    3.libqrencode 
    地址:http://fukuchi.org/works/qrencode/index.en.html 
    php支持请参考:http://hirokawa.netflowers.jp/entry/4900/ 
    4.QRcode Perl CGI & PHP scripts 
    地址:http://www.swetake.com/qr/qr_cgi.html
  • 相关阅读:
    mybatis逆向工程使用
    shiro凭证配置
    shiro基于ini文件入门案例
    springboot实现自定义mvc组件
    ssm整合activiti配置文件和依赖
    activiti网关分支设置
    HTML5新特性 websocket(重点)--多对多聊天室
    HTML5新特性--svg-echarts(重点)-拖动API-WebWorker
    HTML5新特性-- -定时器
    HTML新特性--canvas绘图-文本
  • 原文地址:https://www.cnblogs.com/linuxnotes/p/3667810.html
Copyright © 2020-2023  润新知