Two-dimensional barcode/Two-D code can be divided into stacked/row-type two-dimensional barcode and matrix two-dimensional barcode. Stacked/row-type two-dimensional barcode form is a multiple-line short section of one-dimensional bar code stacked; matrix two-dimensional bar code in the form of a matrix, in the corresponding elements of the matrix in the position of "point" to represent the binary "1", with "null" to represent the binary "0", "point" and "empty" the arrangement of the code.
Stacked/row-type two-dimensional barcode, such as code 16K, code 49, PDF417 and so on.
Matrix two-dimensional code, the most popular than QR code.
Matrix two-dimensional code stores a larger amount of data, can contain numbers, characters, and Chinese text, such as mixed content, there is a certain fault-tolerant (after partial damage can be normal reading), high space utilization.
code is as follows |
&nbs P; |
<?php $vname = ' test '; $vtel = ' 13800000000 '; Generateqrfromgoogle ($vname, $vtel); Function Generateqrfromgoogle ($vname, $vtel, $widhtHeight = ' i ', $EC _level= ' L ', $margin = ' 0 ') { if ($vname && $vtel) { $chl = "BEGIN: vcardnversion:3.0 ". vcard header information "NFN: $vname". "NTEL: $vtel" "Nend:vcard";//vcard tail Information &NBSP;&NBSP Echo ' '; } } |
PHP generated URL two-dimensional code:
The code is as follows |
|
<?php $url = "http://www.google.com.hk"; Generateqrfromgoogle ($url); function Generateqrfromgoogle ($chl, $widhtHeight = ' _level= ', $EC ' L ', $margin = ' 0 ') { Echo ' '; } ?> |
Example
The code is as follows |
|
<?php
/*
* PHP generates two-dimensional code card
* API Google
* Google API two-dimensional code generation "QRCode can store up to 4,296 alphanumeric types of arbitrary text, you can view two-dimensional code data format"
* @param string $chl Two-dimensional code contains information that can be numbers, characters, binary information, Chinese characters. Cannot mix data type, data must pass through UTF-8 url-encoded. If you need to pass more than 2K of information, use the Post method
* @param int $widhtHeight Generate a two-dimensional code size setting
* @param string $EC _level Optional error correction level, QR code supports four levels of error correction, used to restore lost, read-wrong, fuzzy, data.
* L Default: Can identify lost 7% of data
* M can identify data that has lost 15%
* Q can identify lost 25% of data
* H can identify data that has lost 30%
* @param int $margin A two-dimensional code generated from the picture border
* Two-dimensional Code card format---vcard
* Format reference as follows:
Begin:vcard
version:3.0
FN: User name
TEL; CELL; voice:0571-00000000
TEL; WORK; voice:0571-00000000
TEL; WORK; fax:0571-00000000
EMAIL; Pref;internet:361way
url:http://www.111cn.net
The road of Org:361way operation
Role: Research and Development Department
Title:cto
ADR; WORK; Postal: West L. District xxx, Hangzhou city, 310000
rev:2014-2-26t08:30:02z
End:vcard
If you want to customize the required format in more detail, you need to know the format standard of the vcard in detail.
*/
$vcard = Array (
' VName ' => ' username ',
' Vtel ' => ' 13800000000 ',
' vemail ' => ' aaaaa@163.com ',
' vaddress ' => ' hangzhou West L. District ',
);
Generateqrfromgoogle ($vcard);
function Generateqrfromgoogle ($vcard, $widhtHeight = ' i ', $EC _level= ' L ', $margin = ' 0 ')
{
if ($vcard) {
$chl = "begin:vcardnversion:3.0". vcard Header information
"NFN:". $vcard [' VName '].
"NTEL:". $vcard [' Vtel '].
"Nemail:". $vcard [' Vemail '].
"Nadr:". $vcard [' vaddress '].
"Nend:vcard"; vcard Tail Information
Echo ' <img src= ' http://chart.apis.google.com/chart?chs= '. $widhtHeight. ' x '. $widhtHeight. ' &cht=qr&chld= '. $EC _level. ' | ' $margin. ' &chl= '. UrlEncode ($chl). ' alt= ' QR code ' widhtheight= '. $size. ' widhtheight= '. $size. ' " /> ';
}
}
?> |
If you want to achieve the logo in the middle of the effect, need to pass another logo small map to be spliced. This provides only one implementation method, or it can be generated in a qrcode manner.
Vcode's standard information is available in Wikipedia.
Note: Some of the generated pictures have been scanned for data that is not encoded, which is more common in Windows, and because many editors default to the ANSI encoding, changing to UTF8 is OK.