$data = 'www.baidu.com'; include 'phpqrcode.php'; $QRcode = new \QRcode(); ob_start(); $QRcode->png($data); $imageString = base64_encode(ob_get_contents()); ob_end_clean(); echo $imageString;
为什么上面的代码没有输出,要在php里直接生成二维码转base给前端?
Use php qrcode to generate a QR code, how to output it? -PHP Chinese website Q&A-Use php qrcode to generate QR code, how to output it? -PHP Chinese website Q&A
Let’s take a look and learn.
首先你要知道,输出二维码是个图片,你要设置下header吧
header('Content-type: image/jpeg'); header('Content-Disposition: attachment; filename=download_name.jpg');readfile($yourFilePath);
Use php qrcode to generate a QR code, how to output it? -PHP Chinese website Q&A-Use php qrcode to generate QR code, how to output it? -PHP Chinese website Q&A
Let’s take a look and learn.
首先你要知道,输出二维码是个图片,你要设置下header吧