《PHP應(yīng)用:php生成二維碼圖片方法匯總》要點(diǎn):
本文介紹了PHP應(yīng)用:php生成二維碼圖片方法匯總,希望對(duì)您有用。如果有疑問(wèn),可以聯(lián)系我們。
PHP實(shí)例第一種方法:
PHP實(shí)例1,第一種方法:利用使用最廣泛,最方便的Google api技術(shù)實(shí)現(xiàn);
PHP實(shí)例2
PHP實(shí)例
,<?php
//封裝生成二維碼圖片的函數(shù)(方法)
/* 利用google api生成二維碼圖片
$content:二維碼內(nèi)容參數(shù)
$size:生成二維碼的尺寸,寬度和高度的值
$lev:可選參數(shù),糾錯(cuò)等級(jí)
$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實(shí)例3
PHP實(shí)例
/* 使用注意事項(xiàng) 先構(gòu)建內(nèi)容字符串 調(diào)用函數(shù)生成 */
//構(gòu)建內(nèi)容字符串
$content="微信公眾平臺(tái):思維與邏輯rn公眾號(hào):siweiyuluoji";
//調(diào)用函數(shù)生成二維碼圖片
echo create_erweima($content);
//把網(wǎng)址生成二維碼;
$url="http://jingyan.baidu.com/article/0964eca23c39ce8285f5363c.html";
$url.="rn";
$url.="http://jingyan.baidu.com/article/03b2f78c4d28ae5ea237ae15.html";
echo create_erweima($url);
?>
PHP實(shí)例第二種方法:
PHP實(shí)例1,第二種方法使用php類(lèi)庫(kù)PHP QR Code;下載地址:/codes/189897.html ;或者在官網(wǎng)下載:http://phpqrcode.sourceforge.net
PHP實(shí)例2,下載好解壓,然后將phpqrcode文件夾拷貝(或復(fù)制)到項(xiàng)目中去;
PHP實(shí)例3
PHP實(shí)例
,<?php
//引入核心庫(kù)文件
include "phpqrcode/phpqrcode.php";
//定義糾錯(cuò)級(jí)別
$errorLevel = "L";
//定義生成圖片寬度和高度;默認(rèn)為3
$size = "4";
//定義生成內(nèi)容
$content="微信公眾平臺(tái):思維與邏輯;公眾號(hào):siweiyuluoji";
//調(diào)用QRcode類(lèi)的靜態(tài)方法png生成二維碼圖片//
QRcode::png($content, false, $errorLevel, $size);
//生成網(wǎng)址類(lèi)型
$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);
?>
轉(zhuǎn)載請(qǐng)注明本頁(yè)網(wǎng)址:
http://www.snjht.com/jiaocheng/2285.html