thinkphp5 生成二维码海报

function QRcode_create($url)
{
    vendor('phpqrcode.phpqrcode');

    $weburl = '127.0.0.7';
    $value = $url;         //二维码内容
    $errorCorrectionLevel = 'L';  //容错级别
    $matrixPointSize = 5;      //生成图片大小
    // 判断是否有这个文件夹  没有的话就创建一个
    if (!is_dir("qrcode")) {
        // 创建文件加
        mkdir("qrcode");
    }
    $code_path = './qrcode/' . time() . rand(10000, 9999999) . '.png';    //设置二维码文件名
    \QRcode::png($value, $code_path, $errorCorrectionLevel, $matrixPointSize, 2);    //生成二维码
    $image = \think\Image::open('./share.png');
    $filename = '/qrcode/' . time() . rand(10000, 9999999) . '.png';
    $image->water($code_path)->save('.' . $filename);
    @unlink($code_path);
    return $weburl . $filename;
}

猜你喜欢

转载自blog.csdn.net/qq_43929048/article/details/129203801
今日推荐