Home>Article>Backend Development> Generate QR code using PHP class library PHPqrCode
This article mainly introduces the use of PHP class library PHPqrCode to generate QR codes. It has certain reference value. Now I share it with you. Friends in need can refer to it.
PHPqrCode is a PHP 2D code. Code generation class library, you can use it to easily generate QR codes. The official website provides downloads and multiple demonstration demos.
After downloading the class library provided by the official website, you only need to use phpqrcode.php to generate QR codes. Yes, of course your PHP environment must enable support for GD2. phpqrcode.php provides a key png() method, in which the parameter $text indicates the generation of two-digit information text; the parameter $outfile indicates whether to output a QR code image file, the default is no; the parameter $level indicates the fault tolerance rate, that is The covered areas can still be identified, which are L (QR_ECLEVEL_L, 7%), M (QR_ECLEVEL_M, 15%), Q (QR_ECLEVEL_Q, 25%), H (QR_ECLEVEL_H, 30%); The parameter $size indicates the size of the generated image. , the default is 3; the parameter $margin indicates the spacing value of the blank area of the border around the QR code; the parameter $saveandprint indicates whether to save the QR code and display it.
Calling PHP qrCode is very simple. The following code can generate a QR code with the content "http://www.learnphp.cn".
Php code
include 'phpqrcode.php'; QRcode::png('//m.sbmmt.com');
In actual application, we will add our own LOGO in the middle of the QR code to enhance the publicity effect. So how to generate a QR code containing a logo? In fact, the principle is very simple. First use PHP qr Code to generate a QR code image, and then use PHP's image related functions to add the pre-prepared logo image to the middle of the original QR code image just generated, and then regenerate a new one. QR code picture.
'; ?>
The above is the entire content of this article. I hope it will be helpful to everyone's study. For more related content, please pay attention to the PHP Chinese website!
Related recommendations:
php implements socket push technology
How to use Elasticsearch in PHP
The above is the detailed content of Generate QR code using PHP class library PHPqrCode. For more information, please follow other related articles on the PHP Chinese website!