《PHP應用:php生成二維碼圖片方法匯總》要點:
本文介紹了PHP應用:php生成二維碼圖片方法匯總,希望對您有用。如果有疑問,可以聯系我們。
PHP實例第一種方法:
PHP實例1,第一種方法:利用使用最廣泛,最方便的Google api技術實現;
PHP實例2
PHP實例
,<?php
//封裝生成二維碼圖片的函數(方法)
/* 利用google api生成二維碼圖片
$content:二維碼內容參數
$size:生成二維碼的尺寸,寬度和高度的值
$lev:可選參數,糾錯等級
$margin:生成的二維碼離邊框的距離*/
function create_erweima($content, $size = '100', $lev = 'L', $margin= '0') { $content = urlencode($content);
$image = '<img src="http://chart.apis.google.com/...'.$size.'x'.$size.'&cht=qr&chld='.$lev.'|'.$margin.'&chl='.$content.'" widht="'.$size.'" height="'.$size.'" />';
return $image;
}
PHP實例3
PHP實例
/* 使用注意事項 先構建內容字符串 調用函數生成 */
//構建內容字符串
$content="微信公眾平臺:思維與邏輯rn公眾號:siweiyuluoji";
//調用函數生成二維碼圖片
echo create_erweima($content);
//把網址生成二維碼;
$url="http://jingyan.baidu.com/article/0964eca23c39ce8285f5363c.html";
$url.="rn";
$url.="http://jingyan.baidu.com/article/03b2f78c4d28ae5ea237ae15.html";
echo create_erweima($url);
?>
PHP實例第二種方法:
PHP實例1,第二種方法使用php類庫PHP QR Code;下載地址:/codes/189897.html ;或者在官網下載:http://phpqrcode.sourceforge.net
PHP實例2,下載好解壓,然后將phpqrcode文件夾拷貝(或復制)到項目中去;
PHP實例3
PHP實例
,<?php
//引入核心庫文件
include "phpqrcode/phpqrcode.php";
//定義糾錯級別
$errorLevel = "L";
//定義生成圖片寬度和高度;默認為3
$size = "4";
//定義生成內容
$content="微信公眾平臺:思維與邏輯;公眾號:siweiyuluoji";
//調用QRcode類的靜態方法png生成二維碼圖片//
QRcode::png($content, false, $errorLevel, $size);
//生成網址類型
$url="http://jingyan.baidu.com/article/48a42057bff0d2a925250464.html";
$url.="rn";
$url.="http://jingyan.baidu.com/article/acf728fd22fae8f8e510a3d6.html";
$url.="rn";
$url.="http://jingyan.baidu.com/article/92255446953d53851648f412.html";
QRcode::png($url, false, $errorLevel, $size);
?>