教程集 www.jiaochengji.com
教程集 >  脚本编程  >  php  >  正文 利用phpqrcode生成二维码实例代码

利用phpqrcode生成二维码实例代码

发布时间:2016-12-03   编辑:jiaochengji.com
教程集为您提供利用phpqrcode生成二维码实例代码等资源,欢迎您收藏本站,我们将为您提供最新的利用phpqrcode生成二维码实例代码资源
生成二维码是现在各大网站会看到一种功能了,下我们来看看利用phpqrcode库来快速生成二维码实例,希望文章对大家会有所帮助。

QR码详细原理可以参考QR维基百科,中文版介绍比较少,英文版介绍很全面,推荐看英文版的。

Description

PHP QR Code is open source (LGPL) library for generating QR Code, 2-dimensional barcode. Based on libqrencode C library, provides API for creating QR Code barcode images (PNG, JPEG thanks to GD2). Implemented purely in PHP.

Features
•Supports QR Code versions (size) 1-40
•Numeric, Alphanumeric, 8-bit and Kanji encoding.
•Implemented purely in PHP, no external dependencies except GD2
•Exports to PNG, JPEG images, also exports as bit-table
•TCPDF 2-D barcode API integration
•Easy to configure
•Data cache for calculation speed-up
•Debug data dump, error logging, time benchmarking
•Provided merge tool helps deploy library as a one file
•new! API documentation
•new! Over 30 detailed examples
•100% Open Source, LGPL Licensed
Demo


项目地址:http://sourceforge.net/projects/phpqrcode/

Generate fixed size images

* phpqrcode本身未提供固定大小二维码的设置,请参考 http://sourceforge.net/p/phpqrcode/discussion/1111884/thread/f739531a/

 

<table width="620" align="center" border="0" cellpadding="1" cellspacing="1" style="background:#FB7"> <tr> <td width="464" height="27" bgcolor="#FFE7CE"> 代码如下</td> <td width="109" align="center" bgcolor="#FFE7CE" style="cursor:pointer;" onclick="doCopy('copy9169')">复制代码</td> </tr> <tr> <td height="auto" colspan="2" valign="top" bgcolor="#FFFFFF" style="padding:10px;" class="copyclass" id=copy9169>

--- original/phpqrcode/qrimage.php       2010-08-18 07:06:24.000000000 -0700
qrimage.php 2012-07-13 00:51:57.000000000 -0700
@@ -86,10 86,15 @@
                 }
             }
-            $target_image =ImageCreate($imgW * $pixelPerPoint, $imgH * $pixelPerPoint);
-            ImageCopyResized($target_image, $base_image, 0, 0, 0, 0, $imgW * $pixelPerPoint, $imgH * $pixelPerPoint, $imgW, $imgH);

            $targetW = (defined('IMAGE_WIDTH') ? IMAGE_WIDTH : $imgW * $pixelPerPoint );
            $targetH = (defined('IMAGE_HEIGHT') ? IMAGE_HEIGHT : $imgH * $pixelPerPoint );

            $target_image =ImageCreate($targetW, $targetH);

            ImageCopyResized($target_image, $base_image, 0, 0, 0, 0, $targetW, $targetH, $imgW, $imgH);
             ImageDestroy($base_image);
             return $target_image;
         }
-    }
No newline at end of file
    }

用法,设置生成的二维码宽高为 500px

define('IMAGE_WIDTH', 500);
define('IMAGE_HEIGHT', 500);
QRcode::png('http://www.jiaochengji.com/)');

您可能感兴趣的文章:
php动态二维码如何生成
PHP QRCode类库创建中间带LOGO的二维码
使用phpqrcode生成二维码
利用phpqrcode生成二维码实例代码
yii phpqrcode生成二维码实例
php生成二维码的类库(QRCode方法)
php利用PHP QR Code生成二维码(带logo)
php生成二维码实例代码
php 二维码加水印图片 支持ios,android,win8
超简单PHP生成二维码实例

[关闭]
~ ~