二維碼線上產生圖片PHP原始碼_PHP教程

來源:互聯網
上載者:User

二維碼線上產生圖片PHP原始碼


  二維碼現在變得越來越流行了,這裡介紹兩端PHP的二維碼產生代碼,一段使用了Google開放的二維碼API,另一段使用的是PHP QR Code二維碼開源類庫,都很簡單。

  1、使用Google Chart API產生二維碼圖片

  Google Chart API是一個功能十分強大的API,產生二維碼僅僅是其中的一個小功能。這裡只介紹二維碼部分,如果想瞭解更多功能,可以登入官網地址:http://code.google.com/intl/zh-CN/apis/chart/

  代碼如下:

  

  $urlToEncode="http://www.weste.net";

  generateQRfromGoogle($urlToEncode);

  function generateQRfromGoogle($chl,$widhtHeight ='150',$EC_level='L',$margin='0')

  {

  $url = urlencode($url);

  echo '';

  }

  ?>

  產生的二維碼圖片:

  2、使用PHP QR Code產生二維碼圖片

  PHP QR Code是一個開源的php二維碼開源類庫,基於libqrencode C庫,並提供API代碼建立QR條碼映像,支援png、jpg格式。功能強大,使用起來也非常簡單。

  demo代碼如下:

  

  include "./phpqrcode/phpqrcode.php";

  $value="http://www.weste.net";

  $errorCorrectionLevel = "L";

  $matrixPointSize = "4";

  QRcode::png($value, false, $errorCorrectionLevel, $matrixPointSize);

  exit;

  ?>

  產生的二維碼圖片:

http://www.bkjia.com/PHPjc/834967.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/834967.htmlTechArticle二維碼線上產生圖片PHP原始碼 二維碼現在變得越來越流行了,這裡介紹兩端PHP的二維碼產生代碼,一段使用了Google開放的二維碼API,另一段...

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.