PHP generates QR code through PHP QR Code_PHP tutorial
PHP generates QR code through PHP QR Code
1. QR code
QR code, also known as two-dimensional bar code, uses a specific geometric figure to record data symbol information in black and white graphics distributed on a plane (in a two-dimensional direction) according to certain rules. It is clever in coding. Make full use of the concepts of "0" and "1" bit streams that form the basis of computer internal logic, use several geometric shapes corresponding to binary to represent text numerical information, and realize automatic reading through image input equipment or photoelectric scanning equipment. Information is processed automatically. It has some common features of barcode technology: each code system has its own specific character set; each character occupies a certain width; it has certain verification functions, etc. At the same time, it also has the features of automatically identifying different lines of information and processing graphics rotation changes.
2. PHP QR Code download address and case address
3. PHP QR Code implementation simple case and parameter description
<!--?php include 'phpqrcode.php'; $value=http://www.ceshi.com; $errorCorrectionLevel = L; $matrixPointSize = 4; QRcode::png($value, false, $errorCorrectionLevel, $matrixPointSize); ?-->
QRcode::png($data, $filename, $errorCorrectionLevel, $matrixPointSize, $margin);
[1]PHP QR Code supports png, jpg, svg, text and other formats, and the usage method starts with QRcode::svg and other formats.
[2]$data: Indicates the data to be recorded. If it is to store UTF-8 encoded Chinese, the maximum number is 984.
[3]$filename: Saved picture name
[4]$errorCorrectionLevel: Error correction level (L, M, Q, H). The QR code has an error-tolerant function. When part of the QR code image is blocked, it can still be scanned. The higher the fault tolerance rate, the more parts of the QR code image can be blocked.
[5]$matrixPointSize: Pixels of each black point
[6]$margin: white border pixels around the image
5. Common data formats for QR codes
We only need to modify the $data data to achieve the desired effect.
URL (URL)
The generation of QR codes containing URLs is what everyone is most often exposed to (for example: http://www.ceshi.com). The QR code recognition software can know that the data represents a URL through the http:// prefix. Using a syntax format similar to {URLTO:www.ceshi.com} can also allow recognition software to recognize the URL.
E-mail Address
Everyone on the Internet basically uses email when communicating. Of course, the QR code can also save the email address (such as zhaoxiaobo987@163.com). Its syntax format is {mailto:zhaoxiaobo987@163.com}.
Telephone numbers
The data format generated by the QR code of the phone number is very simple and easy to understand: {tel:13161555555}. If it is a landline, add the area code. If you need to contact overseas friends, you need to add the country code +86.
Contact information
There are many standards for contact data formats suitable for QR code generation. For example: vcard (electronic business card). However, its format is a little too complicated for QR codes. At present, as far as the author knows, Android phones on the market (Apple, BlackBerry, etc.) generally support the MECARD data format developed by Japan's docomo company.
MECARD:N:zhaoxiaobo;ADR:beijing,china;TEL:+8613161555555;EMAIL:zhaoxiaobo987@163.com; URL:http://blog.csdn.net/zhao1234567890123456/;QQ:275620501;
BIZCARD
This data format is similar to MECARD, and no specific definition has been found yet. It seems simpler than MECARD; we can only get some inspiration from examples.
BIZCARD:N:zhaoxiaobo;T:Software Engineer;C:Google;A:beijing, China;B:+8613161555555;E:zhaoxiaobo987@163.com;
Text message (SMS)
Grammar format: {smsto:8613161555555:Hello, send text message with QR code}
Multimedia Message (MMS)
Similar to the format of sending text messages: {mmsto:8613161555555:content}
Geographic information
Sharing your current location with friends is undoubtedly a very useful feature. For example, check the location of Google in New York, USA: 40.71872 north latitude, 73.98905 west longitude; height is 100 meters. Syntax format: {geo:40.71872,-73.98905,100}
Get the Android software
When looking for software in Google’s Android market, QR codes can also come in handy. For example: {market://details?id=org.example.foo}
Get Wifi Configuration (Android)
{WIFI:T:WPA;S:mynetwork;P:mypass}. Parameters T (authentication type: WEP or WPA, 'nopass' means no authentication is required), S (SSID of the wireless network), P (password of the wireless network, ignore this if no authentication is required), H (optional. Hidden for SSID of the network).
5. PHP QR Code generates QR code with LOGO
<!--?php include 'phpqrcode.php'; $value = $_GET['url'];//二维码内容 $errorCorrectionLevel = 'L';//容错级别 $matrixPointSize = 6;//生成图片大小 //生成二维码图片 QRcode::png($value, 'qrcode.png', $errorCorrectionLevel, $matrixPointSize, 2); $logo = 'ceshi.png';//准备好的logo图片 $QR = 'qrcode.png';//已经生成的原始二维码图 if ($logo !== FALSE) { $QR = imagecreatefromstring(file_get_contents($QR)); $logo = imagecreatefromstring(file_get_contents($logo)); $QR_width = imagesx($QR);//二维码图片宽度 $QR_height = imagesy($QR);//二维码图片高度 $logo_width = imagesx($logo);//logo图片宽度 $logo_height = imagesy($logo);//logo图片高度 $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; //重新组合图片并调整大小 imagecopyresampled($QR, $logo, $from_width, $from_width, 0, 0, $logo_qr_width, $logo_qr_height, $logo_width, $logo_height); } //输出图片 Header(Content-type: image/png); ImagePng($QR);</pre-->

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Alipay PHP...

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

Session hijacking can be achieved through the following steps: 1. Obtain the session ID, 2. Use the session ID, 3. Keep the session active. The methods to prevent session hijacking in PHP include: 1. Use the session_regenerate_id() function to regenerate the session ID, 2. Store session data through the database, 3. Ensure that all session data is transmitted through HTTPS.

The enumeration function in PHP8.1 enhances the clarity and type safety of the code by defining named constants. 1) Enumerations can be integers, strings or objects, improving code readability and type safety. 2) Enumeration is based on class and supports object-oriented features such as traversal and reflection. 3) Enumeration can be used for comparison and assignment to ensure type safety. 4) Enumeration supports adding methods to implement complex logic. 5) Strict type checking and error handling can avoid common errors. 6) Enumeration reduces magic value and improves maintainability, but pay attention to performance optimization.

The application of SOLID principle in PHP development includes: 1. Single responsibility principle (SRP): Each class is responsible for only one function. 2. Open and close principle (OCP): Changes are achieved through extension rather than modification. 3. Lisch's Substitution Principle (LSP): Subclasses can replace base classes without affecting program accuracy. 4. Interface isolation principle (ISP): Use fine-grained interfaces to avoid dependencies and unused methods. 5. Dependency inversion principle (DIP): High and low-level modules rely on abstraction and are implemented through dependency injection.

How to debug CLI mode in PHPStorm? When developing with PHPStorm, sometimes we need to debug PHP in command line interface (CLI) mode...

How to automatically set the permissions of unixsocket after the system restarts. Every time the system restarts, we need to execute the following command to modify the permissions of unixsocket: sudo...

Sending JSON data using PHP's cURL library In PHP development, it is often necessary to interact with external APIs. One of the common ways is to use cURL library to send POST�...
