关于在thinkcmf中使用phpqrcode生成二维码

首先:下载二维码的类库   phpqrcode文件
 

然后将下载好的文件放到/simplewind/Core/Library/Vendor下

public function scerweima(){


$url=www.baidu.com ;//将url地址写好

 Vendor('phpqrcode.phpqrcode');//加载类库
 
 
$errorCorrectionLevel = 'L'; //容错级别
$i=320;
$j = floor($i/37*100)/100 + 0.01;
$matrixPointSize = $j; //生成图片大小
 
//生成二维码图片
        $filename = SITE_PATH.'public/erweima/'.time().rand(100,999).'.png';//生成二维码的图片名称,以及保存地址
        $QRcode=new \QRcode();//实例化对象
$QRcode::png($url,$filename , $errorCorrectionLevel, $matrixPointSize, 2);
 
$QR = $filename; //已经生成的原始二维码图片文件
$QR = imagecreatefromstring(file_get_contents($QR));
 
 
return $filename;
}

猜你喜欢

转载自www.cnblogs.com/hzhenx/p/9750592.html