/** * 生成二维码 * @param string $url url连接 * @param integer $size 尺寸 纯数字 */ function qrcode($url,$size=4){ Vendor('Phpqrcode.phpqrcode'); // 如果没有http 则添加 if (strpos($url, 'http')===false) { $url='http://'.$url; } QRcode::png($url,false,QR_ECLEVEL_L,$size,2,false,0xFFFFFF,0x000000); }
The first parameter $text; is the URL parameter in the above code;
The second parameter $outfile defaults to No; no file is generated; only the QR code image is returned; otherwise storage needs to be provided Path to generate QR code images;
The third parameter $level defaults to 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 indicate the percentage of the area that the QR code can cover. Taking advantage of the fault tolerance rate of QR code; we can place the avatar in any area of the generated QR code image;
The fourth parameter $size; controls the size of the generated image; the default is 4;
The fifth Parameter $margin; controls the size of the blank area for generating QR codes;
The sixth parameter $saveandprint; saves the QR code image and displays it; $outfile must pass the image path;
The seventh parameter $back_color; Background color;
The eighth parameter $fore_color; the color of drawing QR code;
All resources on this site are contributed by netizens or reprinted by major download sites. Please check the integrity of the software yourself! All resources on this site are for learning reference only. Please do not use them for commercial purposes. Otherwise, you will be responsible for all consequences! If there is any infringement, please contact us to delete it. Contact information: admin@php.cn
Related Article
25 Jul 2016
PHP class library for generating QR codes (QRCode method)
03 Mar 2018
This article mainly shares with you the phpqrcode class library to generate QR code example code, hoping to help everyone.
07 Jul 2018
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.
11 Apr 2023
When we reference some third-party libraries or plug-ins in the Vue project, sometimes we may encounter the problem that the QR code is not generated after deployment. This problem may cause us a lot of trouble and confusion, because QR codes have become a convenient and fast way to transmit information in the current mobile Internet era. So, why is there a problem that the QR code is not generated after the Vue project is deployed? This may be related to some detailed operations we have during the deployment process. Below we will introduce several possible solutions. Solution 1: Check whether the path is correct in the Vue project, 2
13 Jul 2023
Tips for generating simple graphical verification codes using PHP and GD libraries. With the development of the Internet, preventing malicious attacks and abuse has become an indispensable part of website development. CAPTCHA is a technical means widely used to verify user identity and prevent malicious robots from registering and logging in. As a popular server-side programming language, PHP, combined with the GD library, can quickly generate simple graphical verification codes. 1. Introduction to GD library The GD library is an extension library of PHP. It provides a series of functions and methods for processing images. Through the GD library,
14 Jul 2016
Introduction to the use of PHP QR Code, a class library for generating QR codes in PHP. QR codes are used to record data information with specific geometric figures on a flat surface. QR codes are a common two-dimensional code. The QR principle is relatively complicated to understand. If you deal with it yourself, it will probably cost a lot of money.
Hot Tools
PHP library for dependency injection containers
PHP library for dependency injection containers
A collection of 50 excellent classic PHP algorithms
Classic PHP algorithm, learn excellent ideas and expand your thinking
Small PHP library for optimizing images
Small PHP library for optimizing images