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

How to generate QR code using thinkphp framework

little bottle
Release: 2023-04-06 08:06:01
forward
5246 people have browsed it

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">
Copy after login

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); }
Copy after login

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();
 }
Copy after login

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!

Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Latest Issues
Why thinkphp has better performance than laravel?
From 1970-01-01 08:00:00
0
0
0
ThinkPHP Why use composer?
From 1970-01-01 08:00:00
0
0
0
thinkphp versions supported by php6
From 1970-01-01 08:00:00
0
0
0
thinkphp upload files
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template