Home  >  Article  >  Backend Development  >  How to generate QR code using thinkphp framework

How to generate QR code using thinkphp framework

little bottle
little bottleforward
2019-04-22 09:39:285041browse

Request to obtain and display QR code

Nowadays, randomly generated QR codes have become a common network product in our daily lives. In this article, we will tell you how to use ThinkPHP to generate random QR codes. QR code, if you are interested, let’s learn about it together.

Request to obtain and display QR code

    <img src="<?php echo U(&#39;createCode?zsnumber=&#39;.$time.$kcname[&#39;id&#39;].$stuInfo[&#39;id&#39;].&#39;&stuName=&#39;.$stuInfo[&#39;stu_name&#39;].&#39;&sfid=&#39;.$stuInfo[&#39;sfid&#39;].&#39;&kcName=&#39;.$kcname[&#39;classnew&#39;].&#39;&kcid=&#39;.$kcid.&#39;&stuid=&#39;.$stuInfo[&#39;id&#39;].&#39;&#39;);?>" alt="二维码" class="code">

Create QR code

public function createCode(){
        header(&#39;Content-Type: image/png&#39;);
        Vendor(&#39;phpqrcode.phpqrcode&#39;);
        ob_clean();   // 这里一开始我没有加 显示正常  后来就一直显示不了了 之后加上就好了 网上也有几种说法,但是我认为是缓冲区的问题 

$value = &#39;http://XXXXXX/Home/mystudy/showcode?zsnumber=&#39;.$_GET[&#39;zsnumber&#39;].&#39;&stuName=&#39;.$_GET[&#39;stuName&#39;].&#39;&sfid=&#39;.$_GET[&#39;sfid&#39;].&#39;&kcName=&#39;.
$_GET[&#39;kcName&#39;].&#39;&kcid=&#39;.$_GET[&#39;kcid&#39;].&#39;&stuid=&#39;.$_GET[&#39;stuid&#39;].&#39;&#39;; \QRcode::png($value,false, &#39;H&#39;, 8, 2, false); }

QR code link information processing

public function showcode(){
    dump($_GET); 获得二维码中信息
   $temp[&#39;kcid&#39;] =$_GET[&#39;kcid&#39;]; 
  $temp[&#39;userid&#39;] = $_GET[&#39;stuid&#39;]; 
  $info = D(&#39;表名&#39;)->where($temp)->find();
   $this->assign(&#39;info&#39;,$info); 
  $this->display();
 }

Related tutorials: PHP video tutorial

The above is the detailed content of How to generate QR code using thinkphp framework. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:cnblogs.com. If there is any infringement, please contact admin@php.cn delete