php產生二維碼圖片方法匯總

來源:互聯網
上載者:User
第一種方法:

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); ?>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.