Monday, June 24, 2013

PHP: QR code generator

QR code (Quick Response Code) is the trademark for a type of matrix barcode.
PHP QRcode library  can be downloaded:
To use  Qrcode library is quite simple, you just need to include "qrlib.php";
QRcode::png('code data text', 'filename.png') to create output file
QRcode::png('code data text') output code image directly to browser.
Example, first create a post form and post it to qrcode.php
<h1>Jiansen Lu tools -Generate QR Codes</h1><br />

<form action="qrcode.php" method="post">
Input your text here:<br />
  <textarea rows="5" cols="50" name="text1"></textarea><br />
   <input type="submit" value="Create QR Code" />
   <input type="reset"  value="Reset" name="reset" />

In qrcode.php

include "qrlib.php";

//QRcode::png('code data text', 'filename.png'); // creates file
QRcode::png($_POST['text1']); // creates code image and outputs it directly into browser


Or you can directly use index.php as an example, the demo is here:

1 comment: