PHP生成QRCode二維碼

<?php



//引入 phpqrcode 類庫
//phpqrcode下載地址:https://github.com/t0k4rt/phpqrcode
require_once "phpqrcode/qrlib.php";



//第一種(缺省下在網頁中生成二維碼)
//調用QRCode類下的png靜態方法
QRcode::png("this is a qrcode");



$content = "this is a qrcode";	//內容
$filename = time() . ".png";	//文件名
$level = QR_ECLEVEL_L;			//容錯級別
$size = 10;						//尺寸
$padding = 3;					//邊距

//第二種(自定義下在網頁中生成二維碼)
QRcode::png($content, false, $level, $size, $padding, true);

//第三種(自定義下將生成的二維碼保存爲圖片文件)
QRcode::png($content, $filename, $level, $size, $padding, true);



/*容錯級別
QR_ECLEVEL_L 爲常量 0 約可糾錯7%的數據碼字
QR_ECLEVEL_M 爲常量 1 約可糾錯15%的數據碼字
QR_ECLEVEL_Q 爲常量 2 約可糾錯25%的數據碼字
QR_ECLEVEL_H 爲常量 3 約可糾錯30%的數據碼字
*/



?>


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章