search
Homephp教程php手册二维码在线生成图片PHP源代码

二维码在线生成图片PHP源代码

Jun 13, 2016 am 09:29 AM
phppictureonlineflowsource codeNowgeneratecode

二维码在线生成图片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;

  ?>

  生成的二维码图片:

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)