How to Build QR Code Generator Site With PHP QR CODE library

Programming Tutorials – will share the article on how to build a QR code generator site with php qr code library. Perhaps you’ve visited several sites like,,, etc , and you think, how do we build it. We can create qr code generator site with the help of php qr code libraries or using Google’s API chart. Both library or API can be used free of charge and easy to use. The difference is if you build qr code with php qr code library, the entire control stand beside you, in contrast with google chart API, you need to use a third party site. In this article I will be more focus on the use of QR CODE PHP Library.


Before going any further how to create a QR Code generator site, it helps to understand the sense of qr code. QR Code (Quick Response Code) is the development of a Barcode created by Japanese corporation Denso-Wave in 1994. Unlike a barcode that only one side of it containing the data, QR Code has two sides that contain data, and this makes the QR Code more contain information than barcodes. As for example, as follows:

How To Build QR Code Generator Site With PHP QR CODE Library Example

Easy Ways to create qr code using PHP QR CODE library

According to official site php qr code, PHP QR Code is open source (LGPL) library for generating QR Code, 2-dimensional barcode. Based on libqrencode C library, provides API for creating QR Code barcode images (PNG, JPEG thanks to GD2). Implemented purely in PHP, with no external dependencies (except GD2 if needed).

Lets begin the tutorial

1. Download library php qr code here.
2. Your server must support PHP with gd image library (php5-gd). For installation has been much discussed.
3. Create a folder as “qrcode”, then copy the folder phpqrcode (phpqrcode library in zip form) that has been extracted into the folder “qrcode”.
4. There are 2 ways to create qr code image, the first qr code image created temporary and qr code image made permanent. We just need QRcode::png function to create the barcode images

By default QRcode::png function have a standard parameters as follows

static QRcode::png
( $text,
$outfile = false,
$level = QR_ECLEVEL_L,
$size = 3,
$margin = 4,
$saveandprint = false

With the following explanation

  • String $text text string to encode.
  • String $outfile (optional) output file name, if false outputs to browser with required headers.
  • Integer $level (optional) error correction level QR_ECLEVEL_L, QR_ECLEVEL_M, QR_ECLEVEL_Q or QR_ECLEVEL_H.
  • Integer $size (optional) pixel size, multiplier for each ‘virtual’ pixel.
  • Integer $margin (optional) code margin (silent zone) in ‘virtual’ pixels.
  • Boolean $saveandprint (optional) if true code is outputed to browser and saved to file, otherwise only saved to file. It is effective only if $outfile is specified.

For more details you can directly read from the official site

a. Creating temporary qr code image.

For example, create a php file as temporary.php and copy the following code:

the example above create qr code image as follows :

How To Build QR Code Generator Site With PHP QR CODE Library Example

b. Creating permanently qr code.

From the example above, you would create qr code image permanently with the name 023.png in the folder qrcode > phpqrcode > temp

5. To build the qr code generator site, I chose the first way, which makes qr code image temporary. Demo application in the following link.

QR Code Generator Site Demo

In the demo above, I use jquery and bootstrap framework so that the interface look more attractive and mobile responsive.

Tutorial to build qr code generator site using php qr code library, jquery and Bootstrap framework

a. Create an index.php and copy the following script.

b. Create new php file as data.php and copy the following script.

c. Create new php file as parameter.php and copy the following script.

d. Create new CSS file as style.css and copy the following script.

Voila, you’ve managed to create qr code generator site by your self. To download the full script please on the following link

Before finishing this article, I’ll discuss a little bit how to use google chart API to create qr code image

Google provides APIs that can be used to create qr code with the following syntax.

Supporting parameters as follows :

cht=qr : Specifies a QR code.
chs=<width>x<height> : Image size.
chl=<data> : Required The data to encode. Data can be digits (0-9), alphanumeric characters, binary bytes of data, or Kanji. You cannot mix data types within a QR code. The data must be UTF-8 URL-encoded. Note that URLs have a 2K maximum length, so if you want to encode more than 2K bytes (minus the other URL characters), you will have to send your data using POST.

As example below :

it will show image like below

Using QR CODE from google chart API

Another related article :

How To Create QR CODE Image After Published New Article WordPress

Thus article about How to Build QR Code Generator Site With PHP QR CODE library , hope useful 🙂

The following two tabs change content below.
This site is a personal Blog of Sigit Prasetya Nugroho, a Desktop developer and freelance web developer working in PHP, MySQL, WordPress.


 Add your comment
  1. how to save diffrent name qrcode in folder

  2. Hi, I am trying to accomplish something with QR codes and cannot grasp how to do this on a WordPress site. Basically, for every new blog post, I would like a QR code automatically generated to link to that post address, however, I do not want it to display on the page. Rather I want it to be saved to a folder on the server with the filename corresponding to the blog post ID so that it can be retrieved later. Is this possible?

  3. Url not work in your site demo – blank image QR

  4. Hi! there is some problem in this script. i had use this on my website but when put any type of data like url then result not shown. can you guide me what can i do ?

  5. all gui is done but qr code is not generating
    only blank space is in output

  6. Nice tutorial but…

    The following extra files are not called in your index.php so nothing is created…

    b. Create new php file as data.php and copy the following script.


    c. Create new php file as parameter.php and copy the following script.

    Adding the following at least displays the qrcode whereever it is placed but the contents are not correct and need to be modified somewhat.

    html example:

    Also you continually refer to the folder “qrcode” when in fact it should be “phpqrcode”

    Hope you can put things right to help people who can’t get your code example to work.

  7. bagaimana cara nya menambah tulisan dibawah pada hasil qrcode tersebut seperti pada contoh diatas ada tulisan pada hasil qr code

Leave a Comment

Your email address will not be published.

Time limit is exhausted. Please reload CAPTCHA.

This site uses Akismet to reduce spam. Learn how your comment data is processed.