2 Steps to create QR code by google api and php



Step 2: Use Google API to create a QR code

Google provide an interface to help us to create a qr code, by it we can create our qr code very easily, you can know more information in google api.

To show example, i create a demo to show how to a qr code to store up information.

Fox example, i plan to use a qr code to store up informaiton:http://www.stepor.com, you can use code below:


<?php
function generateQRfromGoogle($data,$widhtHeight='150',$EC_level='L',$margin='0'){
 $url=urlencode($data);
 echo '<img src="http://chart.apis.google.com/chart?chs='.$widhtHeight.'x'.$widhtHeight.'&cht=qr&chld='.$EC_level.'|'.$margin.'&chl='.$data.'" widhtHeight="'.$widhtHeight.'" widhtHeight="'.$widhtHeight.'"/>';
}
$data='http://www.stepor.com/';
generateQRfromGoogle($data);
?>

Then save code and open it by my browser, i get a qr code which stores up informaiton:http://www.stepor.comstepor QR code

Category: PHP Programming

TAG:

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>