<?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%的數據碼字 */ ?>