//生成二维码
vendor('topthink.think-image.src.Image');
vendor('phpqrcode.phpqrcode');
error_reporting(E_ERROR);
$url = "https://".$_SERVER['HTTP_HOST']."/home/jiekou/scanning?device_secret=".$vam;
$url = urldecode($url);
$qr_code_path = './public/upload/qr_code/'.date("Y-m-d").'/';
if (!file_exists($qr_code_path)) {
mkdir($qr_code_path);
}
/* 生成二维码 */
$qr_code_file = $qr_code_path.$vam.'_'.rand(1, 100).'.png';
\QRcode::png($url, $qr_code_file,QR_ECLEVEL_M);
//把生成的二维码存入数据库
.........................根据自己需要存入...........................
// $image = $this->mark_photo('图片路径','要显示的名字','保存的路径');//在图片中添加文字
$this->mark_photo($qr_code_file,$vam,$qr_code_file);//在图片中添加文字拼接图片
//函数方法
private function mark_photo($background,$text,$filename){
$image = imagecreatefrompng($background);
$font = './MSYH.TTF'; // 字体文件
$color = imagecolorallocate($image,0,0,0); // 文字颜色
imagettftext($image, 10, 0, 8, 135, $color, $font, $text); // 创建文字
header("Content-Type:image/png");
ImagePng($image, $filename);//保存新生成的
imagedestroy($image);//删除原来的图片
// imagepng($image);//输出图片
}