PHP qrcode 二维码生成

链接:https://pan.baidu.com/s/1hjpXv9IzjA2fPI7FToGRyQ
提取码:6666

 

 

model 代码

<?php
namespace app\admin\model;
class CodeModel {
    public $errorCorrectionLevel = 'L';
    public $matrixPointSize = 4;
    public $flag = false;
    // public $logoaddress = '../public/static/admin/images/map.png';
    
    public function createcode($value){
        require_once '../extend/phpqrcode/phpqrcode.php';
        $files = "qrcode".time().rand(1000,9999).".png";
        
        \QRcode::png($value,$files,$this->errorCorrectionLevel,$this->matrixPointSize,2);
        
        return "/".$files;
    }
}
?>

controller

    public function qrcodes(){
    
        $pu  = new Publics();
        $pus= $pu->random_char();  //方法生成随机数
        $code = new CodeModel();
        $file=$code->createcode($pus);
        $filename1  = '../public'.DS.$file ;
        $filename2  =  '../public'.DS.'uploads'.DS.'QRcode'.DS.$file ;
        copy ( $filename1 ,  $filename2 );  //复制文件
        unlink( $filename1 );
        return $filename2;
        
        
    }

 

posted @ 2021-11-05 15:32  热心居民  阅读(51)  评论(0)    收藏  举报