Home  >  Article  >  Backend Development  >  PHP generates QR code images with background (code example)

PHP generates QR code images with background (code example)

藏色散人
藏色散人forward
2020-01-25 12:28:142549browse

PHP generates QR code images with background (code example)

Quickly produce QR codes with background, it provides you with the following functions:

● Produce original QR codes, configurableurlOr text, and QR code size

● Produce QR code with background. The background size is the size you pass in with background. The original QR code size can be configured. The original When the QR code is in the background, you can return the QR code directly or save it to the path for installation.

Installation

Select

Composer

to install

$ composer require liheng/hart-qr-code

Use

use Hart\QrCode\HartQrcode;
//初始化
/*
* $url = 'http://www.baidu.com' 
* $path = "v1.png"; 背景地址
* $save = false; 是否保存到目录
*/
$hartqrCode = new HartQrcode($url, $path, $save);
//创建原始二维码 必须
$hartqrCode->create_qrcode($size = 200);
//获取原始二维码
$hartqrCode->get_qrcode();
//创建带背景图的二维码 
$hartqrCode->create_bg_qrcode($x = 260, $y = 700, $qrcode_size = 300);
//获取带背景图带二维码
$hartqrCode->get_bg_qrcode();
//获取带背景图的二维码路径 如果没有创建带背景图的二维码 则获取的是原始二维码地址
$hartqrCode->get_qrcode_path();

The above is the detailed content of PHP generates QR code images with background (code example). For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:cnblogs.com. If there is any infringement, please contact admin@php.cn delete