当前位置:网站首页>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 .
边栏推荐
- Defiato is an innovation that combines user-friendly features of a centralized platform with defi services
- 09 route guard authenticates URL
- 2022 Liaoning's latest eight members (Safety Officer) simulated test question bank and answers
- About redis master-slave replication
- 软件测试基础-软件测试历史流程,分类,好处,限制
- Drawing for example study of flashcc
- Awk determines whether the first column is greater than 1. If it is greater than 1, the row will be printed
- Kubernetes basic self-study series | introduction to ingress API
- SQLite net (SQLite is used by unity, WPF and WinForm)
- All you want to know about large screen visualization is here
猜你喜欢
Oracle概念三
软件测试学习-黑马程序员,软件测试学习大纲
当发布/订阅模式遇上.NET
Asemi rectifier bridge kbp210 parameters, kbp210 specifications, kbp210 dimensions
Uploading multiple attachments from canvas apps to SharePoint
Wanzhou gold industry: what are the differences between gold t+d investment and other investments?
Kubernetes basic self-study series | introduction to ingress API
d3dx9_ What if 27.dll is lost? d3dx9_ How to repair 27.dll?
07. Express routing
New products, new personnel and new services, Infiniti will continue to plough into China's future!
随机推荐
leetcode 19. Delete the penultimate node of the linked list
[leetcode] 2. Add two numbers (user-defined listnode), medium
Ten common methods of arrays tools
CDH cluster installation
(5) SPI application design and simulation verification 1 - logic sorting
leetcode 142. Circular linked list II
[multithreading] thread communication scheduling, waiting set wait(), notify()
On array-_-
How to modify / display GPIO status through ADB shell
Seata中 SelectForUpdateExecutor 可以先获取全局锁,再执行 sql吗?
Wanzhou gold industry: what are the differences between gold t+d investment and other investments?
Oracle concept II
Use pyinstaller to package py files into exe. Precautions and error typeerror:_ get_ sysconfigdata_ name() missing 1...‘ check_ Solutions to exists'
seata-server 端数据库连接用户、业务数据库 undo_log 所属用户都需要什么权限?
Synchronization mechanism of dual namenodes
06. First introduction to express
2022 Liaoning latest fire facility operator simulation test question bank and answers
Cloud security daily 220216: root privilege escalation vulnerability found on IBM SaaS integration platform needs to be upgraded as soon as possible
电子智慧套装教程
Study on heritability and field experiment design