时间: 2018-03-11|264次围观|0 条评论

 

require_cache(APP_PATH . 'Lib/phpqrcode/phpqrcode.php'); //引入二维码生成图片,phpqrcode.php自行百度下载

//生成网址的二维码 返回图片地址

function QrCode($token, $url, $size = 8) {
$md5 = md5($token);
$dir = substr($md5, 0, 3) . '/' . substr($md5, 3, 3) . '/' . substr($md5, 6, 3) . '/';
$patch = BASE_PATH . '/attachs/' . 'weixin/' . $dir;
if (!file_exists($patch)) {
mkdir($patch, 0755, true);
}
$file = 'weixin/' . $dir . $md5 . '.png';
$fileName = BASE_PATH . '/attachs/' . $file;
if (!file_exists($fileName)) {
$level = 'L';
if (strstr($url, __HOST__)) {
$data = $url;
}
else {
$data = __HOST__ . $url;
}
QRcode::png($data, $fileName, $level, $size, 2, true);
}
return $file;
}

 t>

本博客所有文章如无特别注明均为原创。
复制或转载请以超链接形式注明转自起风了,原文地址《php 生成二维码
   

还没有人抢沙发呢~