Resource files that need to be used:
Http://files.cnblogs.com/files/Eyes-Chan/phpqrcode-2010100721_1.1.4.zip
In fact, you only need to use the phpqrcode.php in the resource file above. (If you're using a CI framework, just put the phpqrcode.php file in the controller layer)
How to use:
<?php
$str = ' http://www.google.com '; Public function make_qrcode ($str) { include ' phpqrcode.php '; QRCode::p ng ($str); }
?>
If you want to create a QR code and save it directly:
<?PHP//generates a two-dimensional code for a string that is referred to by the $STR and is stored in the path of the $FILENAME's referring generation$str= ' http://www.google.com ';$filename= '/*the URL want to save the QRCode image*/'; Public functionMake_save_qrcode ($str,$filename){ include' Phpqrcode.php '; QRCode::p ng ($str,$filename,$pixelPerPoint= 4,$outerFrame= 4,$saveandprint=false);}?>
If you want to create a QR code with logo and save it directly:
<?PHP$value= ' www.google.com ';//Two-dimensional code content$filename= '/*the URL want to save your QRCode image*/'; Public functionMake_qrcode ($value){ include' Phpqrcode.php '; $errorCorrectionLevel= ' L ';//Fault tolerance level $matrixPointSize= 6;//Generate picture size//Generate two-dimensional code pictureQRCode::p ng ($value, ' Qrcode.png ',$errorCorrectionLevel,$matrixPointSize, 2); $logo= ' logo.png ';//Ready logo Image $QR= ' qrcode.png ';//original two-dimensional code diagram that has been generated if($logo!==FALSE) { $QR= Imagecreatefromstring (file_get_contents($QR)); $logo= Imagecreatefromstring (file_get_contents($logo)); $QR _width= Imagesx ($QR);//Two-dimensional code image width $QR _height= Imagesy ($QR);//Two-dimensional code image height $logo _width= Imagesx ($logo);//logo image Width $logo _height= Imagesy ($logo);//logo Image Height $logo _qr_width=$QR _width/5; $scale=$logo _width/$logo _qr_width; $logo _qr_height=$logo _height/$scale; $from _width= ($QR _width-$logo _qr_width)/2; //Regroup and resize picturesImagecopyresampled ($QR,$logo,$from _width,$from _width, 0, 0,$logo _qr_width,$logo _qr_height,$logo _width,$logo _height); } //Save PictureImagepng ($QR,$filename); }?>
These are the three commonly used methods, so if you need the details of the adjustment, or to meet other requirements, you can study the phpqrcode.php this class library file.
[php]-[01]-Generate and save QR code