Home >Backend Development >PHP Problem >What should I do if php qrcode does not generate images?
The solution to the problem that php qrcode does not generate images: first download phpqrcode and call the phpqrcode class; then open the GD2 extension library support of native PHP.
The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer
What should I do if php qrcode does not generate images?
php qrcode does not generate images. It may be that the GD2 extension library support of php is not enabled.
PHP Use phpqrcode to generate a QR code
What I’m going to talk about today is a bit shallower, a simple and quick way to generate a QR code with text and link content; mainly Call the phpqrcode class, the download address is: https://sourceforge.net/projects/phpqrcode/files/; then turn on the GD2 extension library support of your local PHP (it is turned on by default).
The downloaded package is a compressed package. After opening it, we only need the phpqrcode.php file inside. What we are going to use is the png() method of the QRcode class
The following is a brief explanation of the parameters of the png() method:
The first parameter $text : The content contained in the QR code can be links, text, json strings, etc.;
The second parameter $outfile: The default is false, no file is generated, and only the QR code image is returned for output; Otherwise, you need to give the file name and path to store the generated QR code image;
The third parameter $level: the default is L, the values that can be passed by this parameter are L (QR_ECLEVEL_L, 7%), M (QR_ECLEVEL_M, 15%), Q(QR_ECLEVEL_Q, 25%), H(QR_ECLEVEL_H, 30%), this parameter controls the error tolerance rate of the QR code. Different parameters represent the percentage of the area that the QR code can be covered, that is, covered The area can also be identified;
The fourth parameter $size: controls the size of the generated image, the default is 4;
The fifth parameter $margin: controls the blank area for generating the QR code Size;
The sixth parameter $saveandprint: save the QR code image and display it, $outfile must pass the image path;
Next is the example display:
Effect 1:
Recommended study: "PHP Video Tutorial"
The above is the detailed content of What should I do if php qrcode does not generate images?. For more information, please follow other related articles on the PHP Chinese website!