最近做了个扫描二维码得到vcard的项目,遇到一个问题,有一部分生成完的二维码,用android系统手机扫描后得到的vcard中的中文姓名是乱码,经过比对发现,这部分vcard中ORG这个类型没有内容,随即判断没内容就加上一个固定的字符串,这样乱码的问题得以解决.
php生成二维码的几种方式
1.google开放api,代码如下:
$urlToEncode="http://gz.altmi.com"; generateQRfromGoogle($urlToEncode); function generateQRfromGoogle($chl,$widhtHeight ='150',$EC_level='L',$margin='0') { $url = urlencode($url); echo ''; }
2.php类库PHP QR Code
地址:http://phpqrcode.sourceforge.net/
下载:http://sourceforge.net/projects/phpqrcode/
用例,代码如下:
# 创建一个二维码文件
QRcode::png('code data text', 'filename.png');
# 生成图片到浏览器
QRcode::png('some othertext 1234');
3.libqrencode
地址:http://fukuchi.org/works/qrencode/index.en.html
4.QRcode Perl CGI & PHP scripts
地址:http://www.swetake.com/qr/qr_cgi.html
四、第2种方法中在二维码中间加上logo,修改phpqrcode.php中的QRimage类里的png方法,代码如下:
<?php public static function png($frame, $filename = false, $pixelPerPoint = 4, $outerFrame = 4, $saveandprint = FALSE, $mergePic = '') { $image = self::image($frame, $pixelPerPoint, $outerFrame); 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); }
永久链接:
转载随意!带上文章地址吧。

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

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Atom editor mac version download
The most popular open source editor

Dreamweaver Mac version
Visual web development tools

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

SublimeText3 English version
Recommended: Win version, supports code prompts!
