zoukankan      html  css  js  c++  java
  • php生成二维码的插件phpqrcode

    参考网址:

    http://www.thinkphp.cn/topic/7749.html

    http://blog.csdn.net/stxyc/article/details/44650971

    php生成二维码的几种方式方法:http://blog.csdn.net/small_rice_/article/details/22922455

    我用的是thinkphp框架

    第一步:导入插件,把phpqrcode解压到thinkphp专门摆放第三方插件的地方,我这个项目的是ThinkPHPLibraryVendor,官方的是:ThinkPHP/Extend/Vendor

    第二步:在common/function.php公用函数中添加一个调用函数:

    function qrcode($text=""){
        //include(realpath('D:phpStudyWWWphpqrcodeqrlib.php'));
        //include(realpath('D:phpStudyWWWphpqrcodephpqrcode.php'));
        vendor("phpqrcode.phpqrcode");
         $data = $text;
         $filename =dirname( dirname(dirname( dirname( __FILE__ ) )) )."Uploadsqrcodez"
             .md5($data).".png";
         $errorCorrectionLevel = 'L';
         $matrixPointSize = 2;
         $margin = 5;
        // import("Common.Extend.phppqrcode",'phpqrcode','.php');
        QRcode::png($data, $filename, $errorCorrectionLevel, $matrixPointSize, $margin);
        return "/Uploads/qrcode/z".md5($data).".png";
    }

     第三步:在控制器函数用调用该公共函数

    //生成二维码
            $text= "http://".I( 'server.HTTP_HOST' ).'/Home/Login/register?id='.$userData['ue_id'];
            $erweima=qrcode($text);
            $this->assign('erweima',$erweima);

     第四步:在模板文件中调用

    <img src="{$erweima}" alt="">

    效果图:

    注意的问题:

    1.插件的引入一定要对,可以用include

    2. $filename这个地址很重要,可能是物理地址。

    3.return的地址和$filename有关联,写法又不一样。

    出问题的话基本都是这三个地址没填好。

  • 相关阅读:
    is running beyond physical memory limits. Current usage: 2.0 GB of 2 GB physical memory used; 2.6 GB of 40 GB virtual memory used
    saiku执行速度优化二
    saiku执行速度慢
    saiku 升级&备份&恢复
    saiku 展示优化第二步(要诀和技巧)
    saiku 无密码登陆
    saiku 展示优化
    saiku源代码安装
    结合使用saiku、mondrian workbentch建立多维查询报表
    浅析 mondrian 模式文件 Schema
  • 原文地址:https://www.cnblogs.com/lvchenfeng/p/5290944.html
Copyright © 2011-2022 走看看