PHP generates two-dimensional code via PHP QR code

Source: Internet
Author: User

1, two-dimensional code

Two-dimensional code, also known as a two-dimensional barcode, it is a certain geometry according to a certain pattern in the plane (two-dimensional direction) distribution of the black and white graphics data symbol information, in the code to skillfully use the composition of the computer's internal logic based on the "0", "1" bit stream concept, A number of geometric shapes corresponding to the binary are used to represent the literal numerical information, which is automatically read by the image input device or photoelectric scanning device to realize automatic information processing. It has some common features of barcode technology: Each code system has its specific character set, each character occupies a certain width, and has certain checking function. At the same time, it also has the features of automatic recognition of different lines, and the processing of the change of graphics rotation.

2. PHP QR code and case address

Download: http://sourceforge.net/projects/phpqrcode/files/
Case: http://phpqrcode.sourceforge.net/examples/

3, PHP QR code Implementation of a simple case and parameter description

<?php include ' phpqrcode.php ';       $value = "http://www.ceshi.com"; $errorCorrectionLevel = "L"; $matrixPointSize = "4"; QRCode::p ng ($value, False, $errorCorrectionLevel, $matrixPointSize);? >
Case Description:
QRCode::p ng ($data, $filename, $errorCorrectionLevel, $matrixPointSize, $margin);
[1] PHP QR code supports PNG, JPG, SVG, text and other formats, using the same format as Qrcode::svg.
[2] $data: Represents the data to be recorded, if it is stored utf-8 encoded in Chinese, a maximum of 984.
[3] $filename: Saved picture name
[4] $errorCorrectionLevel: Error correction level (L, M, Q, H), two-dimensional code with fault-tolerant function, when the QR code picture is obscured part, can still be scanned out. The higher the fault tolerance, the more parts of the two-dimensional code image can be obscured.
[5] $matrixPointSize: pixels per Black Point
[6] $margin: white border pixels outside the picture

5, two-dimensional code commonly used data format

We only need to modify the $DATA data to achieve the desired effect.
Web address (URL)
Contains the URL of the two-dimensional code generation is the most common contact (for example: http://www.ceshi.com), QR code recognition software can be known by http://prefix to know that the data represents a Web address. Using a syntax format similar to {URLTO:www.ceshi.com} also allows recognition software to recognize URLs.
e-mail (e-mail address)
e-mail will be used on the Internet when you contact us. Of course, the QR code can also save the email address (e.g. [email protected]). Its syntax format is {Mailto:[email protected]}.

Phone number (telephone numbers)
The data format generated by the QR code of the phone number is simple and easy to understand: {tel:13161555555}. If you have a landline, add a +86 country code to a friend who needs to be contacted overseas.

Contact information (information)
There are a number of criteria for the contact data format to be represented in the form of two-dimensional code generation. For example: vcard (Electronic Business card). However, its format is slightly more complicated for QR codes. At present, as far as I know, the Android phone (Apple, BlackBerry, etc.) in the market generally supports the Mecard data format developed by Japanese DoCoMo company.
Mecard:n:zhaoxiaobo; adr:beijing,china;tel:+8613161555555; Email:[email protected]; url:http://blog.csdn.net/zhao1234567890123456/; qq:275620501;

Bizcard
This data format is similar to Mecard, and no specific definition has been found yet. Seems to be simpler than mecard; it can only be inspired by some examples.
Bizcard:n:zhaoxiaobo; T:software Engineer; C:google; A:beijing, China; b:+8613161555555; E:[email protected];

SMS (SMS)
Syntax format: {smsto:8613161555555: Hello, two-dimensional code texting}

MMS (MMS)
Similar to Text message format: {mmsto:8613161555555: Content}

Location (Geographic information)
Sharing your present position with a friend is undoubtedly a useful feature. For example, see Google's location in New York: North latitude 40.71872, longitude 73.98905, height 100 meters. Syntax format: {geo:40.71872,-73.98905,100}

Get Android software
Looking for software in Google's Android Market, QR codes can also be useful. For example: {Market://details?id=org.example.foo}


Get WiFi configuration (Android)
{WIFI:T:WPA; S:mynetwork; P:mypass}. Parameter T (authentication type: WEP or WPA, ' NoPass ' represents no authentication required), S (SSID of wireless network), P (password for wireless network, ignore if authentication is not required), H (optional). For networks that have a hidden SSID).
5, PHP QR code generation with logo two-dimensional code

<?phpinclude ' phpqrcode.php '; $value = $_get[' url '];//qr code content $errorCorrectionLevel = ' L ';//fault tolerance level $matrixPointSize = 6;//Generate picture size//generate QR code picture qrcode::p ng ($ Value, ' Qrcode.png ', $errorCorrectionLevel, $matrixPointSize, 2); $logo = ' ceshi.png ';///Ready logo image $QR = ' qrcode.png ';//The original two-dimensional code figure already generated  if ($logo!== FALSE) {  $QR = Imagecreatefromstr ING (file_get_contents ($QR));  $logo = imagecreatefromstring (file_get_contents ($logo));  $QR _width = Imagesx ($QR);//QR code image width  $QR _height = Imagesy ($QR);//QR code image height  $logo _width = Imagesx ($logo);// Logo image width  $logo _height = Imagesy ($logo),//logo image height  $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;  Regroup and resize the picture  imagecopyresampled ($QR, $logo, $from _width, $from _width, 0, 0, $logo _qr_width,  $logo _qr_ Height, $logo _width, $logo _height); }//Output picture Header ("Content-type:image/png"); Imagepng ($QR);

PHP generates two-dimensional code via PHP QR code

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.