1.tp->extends添加qrcode/Qrcode.php
檔案地址:https://gitee.com/likxarlit/file_php
2.使用:
use qrcode\Qrcode;
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.uj5u.com/houduan/232290.html
標籤:PHP
上一篇:tp5使用PHPWord(下載引入/composer兩種方式)
下一篇:tp5.1配置支付寶支付
