Generate QR Codes with php (EASY)

Generate QR Codes with php (EASY)

There you go, a function that will generate a QR Code with the help of a function hosted on the Google API servor.

function generate_qr($url, $size ='150', $imgsize = false, $EC_level='L', $margin='0') {
    $url = urlencode($url);
    return '<img src="http://chart.apis.google.com/chart?chs='.$size.'x'.$size.&cht=qr&chld='.$EC_level.'|'.$margin.'&chl='.$url.'" alt="QR code" width="'.($imgsize ? $imgsize : $size).'" height="'.($imgsize ? $imgsize : $size).'" />';
}

You call it like this:

<?php echo generate_qr('http://blog.zurka.us'); ?>

And get something like this:

blog.zurka.us qr code

Try pointing your favorite code reader at it!

PS: I just noticed that it doesn’t work well because of the dark background, try it here.

If you liked this post think about subscribing to my RSS feed and prevent missing anything interesting. It's free, fast and doesn't hurt. Promise. Click here.
Rate this post:

4 Comments »

  1. Atef Says:

    I <3 it Thanks for sharing :)

  2. chased Says:

    Terrific work! This is the type of information that should be shared around the web. Shame on the search engines for not positioning this post higher!

  3. Iris Says:

    Barcode is very easy to produce. Here are few websites that can help you do this. Choose whatever you want.

RSS feed for comments on this post. TrackBack URL

Leave a comment