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

php生成二维码程序代码

WBOY
Release: 2016-06-13 11:27:40
Original
1155 people have browsed it

生成二维码程序在网上可以找到很多我们发现像google,还有一些国外站都提供了免费生成二维码的插件或api了,下面我来给大家介绍几种。

最简单最实例的goolge开源方法

1.google开放api

 代码如下 复制代码

$urlToEncode="http://gz.altmi.com";
generateQRfromGoogle($urlToEncode);
function generateQRfromGoogle($chl,$widhtHeight ='150',$EC_level='L',$margin='0')
{
    $url = urlencode($url); 
    echo 'QR code

widhtHeight="'.$size.'" widhtHeight="'.$size.'"/>';
}

上面的方法简单快速,只要几句话即可,不足之处是调用了google服务器东西,如果google不提供服务了我们就无法

成了,下面再看

2.php类库PHP QR Code

地址:http://phpqrcode.sourceforge.net/
下载:http://sourceforge.net/projects/phpqrcode/

 代码如下 复制代码

   include('./phpqrcode/phpqrcode.php');
   // 二维码数据
   $data = 'http://gz.altmi.com';
   // 生成的文件名
   $filename = $errorCorrectionLevel.'|'.$matrixPointSize.'.png';
   // 纠错级别:L、M、Q、H
   $errorCorrectionLevel = 'L'; 
   // 点的大小:1到10
   $matrixPointSize = 4; 
   QRcode::png($data, $filename, $errorCorrectionLevel, $matrixPointSize, 2);
?>

这个还不错保存在自己服务器,现在还有一些如有:libqrencode与QRcode Perl CGI & PHP scripts二维码生成插件大

家喜欢也可看看。


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 Recommendations
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!