1. 程式人生 > >thinkphp 5 生成二維碼案例

thinkphp 5 生成二維碼案例

php

vendor("phpqrcode.phpqrcode");

$url=‘http://www.dc3688.com/mobile/User/qrurl/?userid=‘."$this->user_id";

$level=3;

$size=4;

$errorCorrectionLevel =intval($level) ;//容錯級別

$matrixPointSize = intval($size);//生成圖片大小

$path = "public/upload/qrcode/";

if(!file_exists($path))

{

mkdir($path, 0700);

}

$username=$this->user_id;

$fileName = $path.$username.‘.png‘;

//生成二維碼圖片

//echo $_SERVER[‘REQUEST_URI‘];

$object = new \QRcode();

$object->png($url, $fileName, $errorCorrectionLevel, $matrixPointSize, 2);

$result[‘qcode‘]=$fileName;


thinkphp 5 生成二維碼案例