QR Code in PHP

Technology keeps on growing. Nowadays in web everyone needs the QR code.

Brief on QR Code:

A QR code (abbreviated from Quick Response code) is a type of matrix barcode (or two-dimensional code) first designed for the automotive industry. More recently, the system has become popular outside of the industry due to its fast readability and comparatively large storage capacity. The code consists of black modules arranged in a square pattern on a white background. The information encoded can be made up of any kind of data (e.g., binary, alphanumeric, or Kanji symbols)

Eg: You convey message/Address/Phone etc., through QR code

Using PHP we can develop the QR code.

<?php
function generateQRwithGoogle($chl,$widhtHeight ='150',$EC_level='L',$margin='0') {
    echo '<img src="http://chart.apis.google.com/chart?chs='.$widhtHeight.
'x'.$widhtHeight.'&cht=qr&chld='.$EC_level.'|'.$margin.
'&chl='.$chl.'" alt="QR code" widhtHeight="'.$widhtHeight.
'" widhtHeight="'.$widhtHeight.'"/>';
}
if(isset($_POST['Go'])){
$urlToEncode = $_POST['urlToEncode'];
generateQRwithGoogle($urlToEncode);
}
?>
<form method="post" action="" name="ff1" id="ff1">
<input type="hidden" name="process" id="process" value="1">
QR encode: <input type="text" name="urlToEncode" id="urlToEncode" style="width:220px;"><input type="submit" name="Go" value="Go">
</form>
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s