第一種方法:
1,第一種方法:利用使用最廣泛,最方便的Google api技術實現;
2
,<?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;}
/* 使用注意事項 先構建內容字串 調用函數產生 *///構建內容字串$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);?>
第二種方法:
下載好解壓,然後將phpqrcode檔案夾拷貝(或複製)到項目中去;
,<?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); ?>