Reputation: 71
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?
Upvotes: 3
Views: 1367
Reputation: 41958
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.
Upvotes: 5
Reputation: 2441
The library you're using sends the data as an image, once you send text too you're corrupting the image.
Upvotes: 1