Generate QR Code Using PHP
Generate and Save the QR Code as a PNG image.
In this tutorial, we are going to see how to generate the QR code using PHP. Recently I had a requirement to generate a QR code and create a PDF with the QR code. I am sharing the code in this tutorial.
There are many third-party libraries are available to generate the QR code using PHP. I chose the PHP QR Code library. My requirement is very simple. This library is a perfect match for my requirement. Later I will try other PHP QR code libraries and will share those codings too.
The codes are tested using PHP 7.2 on macOS. We will see how to generate the QR code in step by step example.
Download Library:
Download the QR library using the below link.
https://sourceforge.net/projects/phpqrcode/files/
After download, please extract the zip file and paste it inside the htdocs folder. I created a folder named qrcode in the htdocs folder and pasted the extracted folder inside it.
Generate QR Code And Display In Browser:
The syntax for generating QR codes is given below.
QRcode::png($text, $file, $ecc, $pixel_size, $frame_size);
- $text => Mandatory parameter. Other parameters are optional. The data to be…