直接上代码,phpqrcode包自行下载。
<?php
class ControllerTestQrcode extends Controller
{
/**
* 用於生成一個二維碼
*/
public function index(){
include_once DIR_PHPQRCODE."phpqrcode.php";
$size = floor(($this->request->get['width'] ?? 150)/37*100)/100;
$qrcode = new \QRcode();
$type = $this->request->get['type'] ?? 1;
$code = $this->request->get['code'] ?? '';
// 拼接二维码图片地址
$shareimg = $code . '.png';
$file_path = $this->creatMkdirs(DIR_IMAGE.'phpqrcode/'.date('Ymd').'/');
$shareimg = $file_path. $shareimg;
/**
*
* png参数说明:
*