技术文章
php根据链接生成二维码图片
发布日期:2019-11-16 阅读次数:2319 字体大小:
//生成二维码图片,返回图片路径
function scerweima($url){
    $value = $url;         //二维码内容,此处是链接地址
    $errorCorrectionLevel = 'L';  //容错级别
    $matrixPointSize = 5;      //生成图片大小
    //生成二维码图片
    $filename = '/f/image/qrcode/'.getuid().'.png';  //可生成不同的文件名字,getuid()为随机数函数,保存图片地址
    QRcode::png($value,$filename , $errorCorrectionLevel, $matrixPointSize, 2);
    $QR = $filename;        //已经生成的原始二维码图片文件
    $QR = imagecreatefromstring(file_get_contents($QR));
    //输出图片
    imagepng($QR, 'qrcode.png');
    imagedestroy($QR);
}