Home > php教程 > php手册 > body text

Google 二维码 PHP API

WBOY
Release: 2016-06-21 08:49:28
Original
1034 people have browsed it

什么是二维码:
二维码是二维条形码的一种,可以将网址、文字、照片等信息通过相应的编码算法编译成为一个方块形条码图案,手机用户可以通过摄像头和解码软件将相关信息重新解码并查看内容。
读取方式:
利用30万画素以上的照相手机,搭配手机内的QR码解码软件,对着QR码一照,解码软件会自动解读此讯息,显示于手机屏幕上面。目前也有运用到Webcam的镜头来解码,预计未来所有有镜头的科技产品,都会被导入此QR码的机制。

二维条形码的优势:
1.数据容量更大
2.超越了字母数字的限制
3.条形码相对尺寸小
4.具有抗损毁能力

二维码生成

:https://chart.googleapis.com/chart?cht=qr&chs=150×150&choe=UTF-8&chld=L4&chl=http://blog.waphk.cn

google开放api【PHP版】

 

 

 

 

 

 

PHP

1

2

3

4

5

6

7

8

//PHP Code

$urlToEncode="blog.php100.com";

generateQRfromGoogle($urlToEncode);

function generateQRfromGoogle($chl,$widhtHeight ='150',$EC_level='L',$margin='0')

{

$url = urlencode($url);

echo 'QR code';

}

参数1 cht 指定一个QR码
参数2 chs 图像大小,这是说生成图片尺寸为200×200,是宽x高。这并不是生成图片的真实尺寸,应该是最大尺寸。
参数3 chl 指定的数据,也就是解码后看到的信息。包含中文时请使用UTF-8编码汉字,否则将出现问题。
有两个可选参数
choe 编码 默认UTF8
chld 错误校正 默认7% L代表默认纠错水平; 4代表二维码边界空白大小,可自行调节。



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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!