iBlog random » generator http://blog.zurka.us Just another WordPress weblog Tue, 28 May 2013 20:28:47 +0000 en-US hourly 1 http://wordpress.org/?v=3.6 Generate QR Codes with php (EASY) http://blog.zurka.us/generate-qr-codes-with-php-easy/ http://blog.zurka.us/generate-qr-codes-with-php-easy/#comments Thu, 24 Jun 2010 22:30:19 +0000 nasal http://blog.zurka.us/?p=1079

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.

]]>
http://blog.zurka.us/generate-qr-codes-with-php-easy/feed/ 4