Recently done a scan two-dimensional code to get a vcard project, encountered a problem, a part of the generated two-dimensional code, using the Android phone after scanning the Chinese name of the vcard is garbled, after the discovery, this part of the vcard org this type has no content, Immediately judged no content to add a fixed string, so garbled problem can be solved. This solution is a curve to save the nation, do not know how to solve the garbled problem, who get the method please leave a message, thank you.
Three, PHP generation of two-dimensional code several ways
1.google Open API
The code is as follows |
|
$urlToEncode = "http://gz.altmi.com"; Generateqrfromgoogle ($urlToEncode); function Generateqrfromgoogle ($chl, $widhtHeight = ' _level= ', $EC ' L ', $margin = ' 0 ') { $url = UrlEncode ($url); Echo '; } |
2.php class library PHP QR Code
Address: http://phpqrcode.sourceforge.net/
Download: http://sourceforge.net/projects/phpqrcode/
Case:
The code is as follows |
|
# Create a two-dimensional code file QRCode::p ng (' Code data text ', ' filename.png '); # Generate pictures to Browser QRCode::p ng (' some othertext 1234 '); |
3.libqrencode
Address: http://fukuchi.org/works/qrencode/index.en.html
PHP support please refer to: http://hirokawa.netflowers.jp/entry/4900/
4.QRcode Perl CGI & PHP Tutorials Scripts
Address: http://www.swetake.com/qr/qr_cgi.html
The 2nd method is to add a logo in the middle of the two-dimensional code.
To modify the PNG method in the Qrimage class in phpqrcode.php:
code is as follows |
&nbs P; |
public static function png ($frame, $filename = False, $pixelPerPoi NT = 4, $outerFrame = 4, $saveandprint =false, $mergePic = ') { $image = Self::image ($frame, $pixelPerPoint, $outerF Rame); if ($mergePic) { $im = imagecreatefrompng ($mergePic); $w = Imagesx ($im); $h = Imagesy ($im); Imagealphablending ($image, true); Imagealphablending ($im, true); $qrw = (Imagesx ($image)-$w)/2; $qrh = (Imagesy ($image)-$h)/2; Imagecopy ($image, $im, $QRW, $QRH, 0, 0, $w, $h); Imagedestroy ($im); } if ($filename = = False) { Header ("Content-type:image/png"); Imagepng ($image); } else { Imagepng ($image, $filename); if ($saveandprint ===true) { Header ("Content-type:image/png"); Imagepng ($image); } } Imagedestroy ($image); } |