PHP code example of khalilleo-webagentur / php-qrcode

1. Go to this page and download the library: Download khalilleo-webagentur/php-qrcode library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

khalilleo-webagentur / php-qrcode example snippets



// sample HTML



rCode;
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



use Khalilleo\QrCode\QrCode;
use Khalilleo\QrCode\QrHelper;

CT_LEVEL_L);

$im = $qr->createImage(2, 4);

header("Content-type: image/gif");
imagegif($im);

imagedestroy($im);




// sample XML

\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>");