Home > Backend Development > PHP Tutorial > PHP generates QR code through PHP QR Code_PHP tutorial

PHP generates QR code through PHP QR Code_PHP tutorial

WBOY
Release: 2016-07-13 10:18:05
Original
1049 people have browsed it

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 &#39;phpqrcode.php&#39;; 
      
$value=http://www.ceshi.com;
$errorCorrectionLevel = L;
$matrixPointSize = 4;
QRcode::png($value, false, $errorCorrectionLevel, $matrixPointSize);
?-->
Copy after login
Case description:
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 &#39;phpqrcode.php&#39;; 
$value = $_GET[&#39;url&#39;];//二维码内容 
$errorCorrectionLevel = &#39;L&#39;;//容错级别 
$matrixPointSize = 6;//生成图片大小 
//生成二维码图片 
QRcode::png($value, &#39;qrcode.png&#39;, $errorCorrectionLevel, $matrixPointSize, 2); 
$logo = &#39;ceshi.png&#39;;//准备好的logo图片 
$QR = &#39;qrcode.png&#39;;//已经生成的原始二维码图 
 
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-->

Copy after login

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/885679.htmlTechArticlePHP generates QR code through PHP QR Code 1. QR code QR code, also known as QR barcode, It uses a specific geometric figure to distribute black and white on a plane (in a two-dimensional direction) according to certain rules...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template