当前位置:网站首页>TP5 generates the most detailed two-dimensional code tp6 (also available)
TP5 generates the most detailed two-dimensional code tp6 (also available)
2022-06-27 18:23:00 【When you're lonely, the dog stays with you】
effect :

One : download phpqrcode Class file
1. Download address :PHP QR Code download | SourceForge.net
After downloading, unzip it and put it in tp5 In the framework vendor Below directory (vendor Generally store third-party plug-ins )


2.PHP The environment must turn on support GD2 Extended library support ( It's usually on )
3. The preparations are all done , The next step is the code part , Just write and call the following methods in the controller , You can see the QR code you want
Be careful : The following code is tp5 Generate qr code ,tp6 Words Use require introduce phpqrcode.php, Just open tp6 notes , notes tp5 vendor Methods introduced
/// QR code public function createImg($url='') { vendor('phpqrcode.phpqrcode');// Introducing class library tp5 // require "../vendor/phpqccode/phpqrcode.php";//tp6 Introducing class library methods $value = $url; // QR code content $errorCorrectionLevel = 'L'; // Fault tolerance level $matrixPointSize = 5; // Generate image size // Generate QR code image // Determine whether this folder exists If not, create one if (!is_dir("qrcode")) { // Create file plus mkdir("qrcode"); } // Set the QR code file name $filename = './qrcode/' . time() . rand(10000, 9999999) . '.png'; // Generate qr code \QRcode::png($value, $filename, $errorCorrectionLevel, $matrixPointSize, 2); return $filename; }
4. call
Use the call where you need it , The two-dimensional code will be generated and returned to us with a path , The picture is already in public/qrcode/ To generate, you only need to splice our domain name to access
$img = $this-> createImg($orderNumber);// QR code path 5.
This is the third step if you need to convert base64 Data paste the following code can be slightly modified
// If you need to convert to base64 data , Just untangle the line below
//$image_data = chunk_split(base64_encode(fread(fopen($filename, 'r'), filesize($filename))));
// Get the current domain name $request = Request::instance(); $domain = $request->domain();
return $domain.'/'.$filename;
} belt logo Two dimensional code
function scerweima1($url=''){
Vendor('phpqrcode.phpqrcode');
$value = $url; // QR code content
$errorCorrectionLevel = 'H'; // Fault tolerance level
$matrixPointSize = 6; // Generate image size
// Generate QR code image
$filename = './qrcode/' . time() . rand(10000, 9999999) . '.png';
QRcode::png($value,$filename , $errorCorrectionLevel, $matrixPointSize, 2);
$logo = VENDOR_PATH.'phpqrcode\images'.'\logo.png'; // Ready logo picture
$QR = $filename; // The original QR code graph that has been generated
if (file_exists($logo)) {
$QR = imagecreatefromstring(file_get_contents($QR)); // Target image connection resource .
$logo = imagecreatefromstring(file_get_contents($logo)); // Source image connection resource .
$QR_width = imagesx($QR); // QR code image width
$QR_height = imagesy($QR); // QR code image height
$logo_width = imagesx($logo); //logo Image width
$logo_height = imagesy($logo); //logo Picture height
$logo_qr_width = $QR_width / 4; // After the combination logo Width ( Take up... Of QR code 1/5)
$scale = $logo_width/$logo_qr_width; //logo Width scaling ratio ( The width of itself / Combined width )
$logo_qr_height = $logo_height/$scale; // After the combination logo Height
$from_width = ($QR_width - $logo_qr_width) / 2; // After the combination logo The coordinate point of the upper left corner
// Recombine the picture and resize
/*
* imagecopyresampled() Put an image ( Source image ) Copy a square area in to another image
*/
imagecopyresampled($QR, $logo, $from_width, $from_width, 0, 0, $logo_qr_width,$logo_qr_height, $logo_width, $logo_height);
}
// Output pictures
imagepng($QR, 'qrcode.png');
imagedestroy($QR);
imagedestroy($logo);
return '<img src="qrcode.png" alt=" Use wechat to scan payment ">';
}
The same way .边栏推荐
- Sword finger offer 22 The penultimate node in the linked list
- Generate zip package command
- What do fast fashion brands care more about?
- Software testing - the concept of testing, the detailed introduction of unit testing, and how to design test cases
- [UVM basics] set a monitor at the input port of the DUT to explain the necessity
- 软件测试-测试的概念,单元测试的详细介绍,如何设计测试用例
- Anfulai embedded weekly report (issue 252): February 7, 2022 to February 13, 2022
- 如何制作登录界面
- Oracle TRUNC function processing date format
- (POJ - 1847) tram (shortest circuit)
猜你喜欢

Defiato is an innovation that combines user-friendly features of a centralized platform with defi services

Autodesk Navisworks 2022软件安装包下载及安装教程

When the publish / subscribe mode encounters NET

d3dx9_ How to repair 38.dll? d3dx9_ 38. How to download a missing DLL?

Common optimization techniques for Web Performance

Lvgl8.x migrating to stm32f4

ROS "topic" programming implementation

Leetcode 46 Full Permutation

全面解析零知识证明:消解扩容难题 重新定义「隐私安全」

Byte + Google super full kotlin learning King fried notes! Kotlin introductory tutorial + Advanced kotlin enhanced actual combat (with demo)
随机推荐
How to modify / display GPIO status through ADB shell
Wanzhou gold industry: what are the differences between gold t+d investment and other investments?
10 minutes to master the installation steps of MySQL
2022 Liaoning latest fire facility operator simulation test question bank and answers
Lvgl8.x migrating to stm32f4
Defiato is an innovation that combines user-friendly features of a centralized platform with defi services
Asemi rectifier bridge kbp210 parameters, kbp210 specifications, kbp210 dimensions
Awk determines whether the first column is greater than 1. If it is greater than 1, the row will be printed
DOM object in JS
When the publish / subscribe mode encounters NET
Part 32 supplement (32) string of ECMAScript
d3dx9_ How to repair 38.dll? d3dx9_ 38. How to download a missing DLL?
电子智慧套装教程
软件测试学习-黑马程序员,软件测试学习大纲
Oracle concept II
JXL export Excel
[the way of programmer training] - 3 Character count statistics
New products, new personnel and new services, Infiniti will continue to plough into China's future!
Generate zip package command
How to write a resume?