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>
还没有人抢沙发呢~