tp5.1生成二维码

1.tp->extends添加qrcode/Qrcode.php

文件地址:https://gitee.com/likxarlit/file_php
2.使用:
use qrcodeQrcode;
public function UserImg()
{
  $value = 'https://www.cnblogs.com/junyi-bk/'; //二维码内容
  $errorCorrectionLevel = 'L'; //容错级别
  $matrixPointSize = 5; //生成图片大小
  //生成二维码图片
  // 判断是否有这个文件夹 没有的话就创建一个
  if (!is_dir("qrcode")) {
  // 创建文件加
    mkdir("qrcode");
  }
  //设置二维码文件名
  $filename = 'qrcode/' . time() . rand(10000, 9999999) . '.png';
  //生成二维码
  Qrcode::png($value, $filename, $errorCorrectionLevel, $matrixPointSize, 2);
  //获取当前域名
  $url = $this->getWebUrl().'/'.$filename;
  return $url;
}

//获取域名

public function getWebUrl(){
  return request()->scheme().'://'.request()->host();
}

原文地址:https://www.cnblogs.com/ljkltt/p/14109873.html