PHP QR Code Function

First thing first, it does not generate image file but embed one from Nokia.com, here it is...

function QR($text, $size = "m"){
    switch($size){ //select size
        case "s": $size = 2; break;
        case "m": $size = 4; break;
        case "l": $size = 6; break;
        default: $size = 4;
    }
    $text = urlencode($text); //URL encoding, we don't want to break anything
    $src = "http://mobilecodes.nokia.com/qr?DATA=$text&MODULE_SIZE=$size&name=&MARGIN=2&ENCODING=BYTE&type=text&MODE=TEXT&a=create"; //generate URL
    return '<img alt="" src="'.$src.'"/>'; //return image
}


Now just by calling...

echo QR("http://webarto.com", "l");

We get...



You can check if image above is valid with your favorite smartphone



©2009-2011 Webarto • web design & development • Tuzla // Sarajevo // Beograd