引入phpqrcode文件,调用QRcode::png方法生成二维码
function scerweima($url=''){
require_once('../cmobile/control/qrcode/phpqrcode/phpqrcode.php');
$value = $url; //二维码内容
$errorCorrectionLevel = 'L'; //容错级别
$matrixPointSize = 5; //生成图片大小
//生成二维码图片
$filename = BASE_UPLOAD_PATH.DS.'qrcode'.DS.microtime().'.png';
QRcode::png($value,$filename , $errorCorrectionLevel, $matrixPointSize, 2);
$QR = $filename; //已经生成的原始二维码图片文件
$QR = imagecreatefromstring(file_get_contents($QR));
//输出图片
$file = time().'qrcode.png';
imagepng($QR, $file);
imagedestroy($QR);
return c('main_url_main')."/bmobile/".$file;
}
本文介绍了一种使用PHP生成二维码的方法。通过引入phpqrcode文件并调用QRcode::png方法,可以将指定的内容转换为二维码图片。该过程包括设置二维码的容错级别、图片大小,并最终输出生成的二维码。
5828

被折叠的 条评论
为什么被折叠?



