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

PHP generates QR code images with background (code example)

藏色散人
Release: 2023-04-08 10:06:02
forward
2646 people have browsed it

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
Copy after login

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();
Copy after login

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!

Related labels:
php
source:cnblogs.com
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template