Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generate qr code by using php

Tags:

php

qr-code

I used the github php qrcode library. I can generate the qr code with no problem. How ever if the generate it and echo some words then the qr code scrambled.

My code is as follow:

<?php 
 include "phpqrcode/qrlib.php";
 $link = "http://mail.gmail.com";
 echo "ABC";
 QRcode::png($link);
?>

if I comment the echo "ABC", the qr code is fine. Why this happened?

like image 843
user3118482 Avatar asked Mar 28 '26 09:03

user3118482


1 Answers

The png function creates the image and streams its file contents to the browser directly. Echoing data in between is like editing the image in Notepad and inserting random data, thus corrupting the image.

like image 161
Niels Keurentjes Avatar answered Mar 30 '26 00:03

Niels Keurentjes