khallilleo-webagentur / php-qrcode
PHP QR码生成库
v1.0.0
2024-04-17 20:18 UTC
Requires
- php: ^8.1
README
PHP QR码生成库。
要求
- PHP
^8.1
安装
composer require khalilleo-webagentur/php-qrcode
使用方法
// sample HTML <?php require 'vendor/autoload.php'; use Khalilleo\QrCode\QrCode; use Khalilleo\QrCode\QrHelper; $qr = new QRCode(); // QrHelper::QR_ERROR_CORRECT_LEVEL_L (7%) // QrHelper::QR_ERROR_CORRECT_LEVEL_M : (15%) // QrHelper::QR_ERROR_CORRECT_LEVEL_Q : (25%) // QrHelper::QR_ERROR_CORRECT_LEVEL_H : (30%) $qr->setErrorCorrectLevel(QrHelper::QR_ERROR_CORRECT_LEVEL_L); $qr->setTypeNumber(4); $anyString = "https://www.khalilleo.com"; $qr->addData($anyString); $qr->make(); $qr->printHTML(); echo "<br><br>"; $qr = QrCode::getMinimumQRCode($anyString, QrHelper::QR_ERROR_CORRECT_LEVEL_L); $qr->printHTML();
// sample image <?php use Khalilleo\QrCode\QrCode; use Khalilleo\QrCode\QrHelper; require 'vendor/autoload.php'; $qr = QrCode::getMinimumQRCode("https://www.khalilleo.com", QrHelper::QR_ERROR_CORRECT_LEVEL_L); $im = $qr->createImage(2, 4); header("Content-type: image/gif"); imagegif($im); imagedestroy($im);
<?php // sample XML require 'vendor/autoload.php'; use Khalilleo\QrCode\QrCode; use Khalilleo\QrCode\QrHelper; $qr = QrCode::getMinimumQRCode("https://www.khalilleo.com", QrHelper::QR_ERROR_CORRECT_LEVEL_L); header("Content-type: text/xml"); print("<qrcode>"); for ($r = 0; $r < $qr->getModuleCount(); $r++) { print("<line>"); for ($c = 0; $c < $qr->getModuleCount(); $c++) { print($qr->isDark($r, $c)? "1" : "0"); } print("</line>"); } print("</qrcode>");
致谢
版权
本项目采用MIT许可证。