PHP code example of jysperu / php-qr-code
1. Go to this page and download the library: Download jysperu/php-qr-code 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/ */
jysperu / php-qr-code example snippets
spl_autoload_register(function ($class) {
static $dir = '/path/to/src';
static $spc = '\\';
$class = trim($class, $spc);
$parts = explode($spc, $class);
$base = array_shift($parts);
if ($base <> 'QRcode' or count($parts) === 0) return;
$parts = implode(DIRECTORY_SEPARATOR, $parts);
$file = $dir . DIRECTORY_SEPARATOR . $parts . '.php';
if (file_exists($file))
use QRcode\QRcode;
use QRcode\QRstr;
$data = 'Hello World!';
$dest = __DIR__ . '/qr.png';
QRcode :: png ($data, $dest, QRstr :: QR_ECLEVEL_L, 4, 2);
## Expected: New file
use QRcode\QRcode;
use QRcode\QRstr;
$data = 'Hello World!';
$dest = __DIR__ . '/qr.webp';
QRcode :: webp ($data, $dest, QRstr :: QR_ECLEVEL_L, 4, 2);
## Expected: New file
use QRcode\QRcode;
use QRcode\QRstr;
$data = 'Hello World!';
QRcode :: png ($data, FALSE, QRstr :: QR_ECLEVEL_L, 4, 2);
## Expected: Header: Content-type: image/png
use QRcode\QRcode;
use QRcode\QRstr;
$data = 'Hello World!';
QRcode :: webp ($data, FALSE, QRstr :: QR_ECLEVEL_L, 4, 2);
## Expected: Header: Content-type: image/webp
use QRcode\QRcode;
use QRcode\QRstr;
$data = 'Hello World!';
$base64_data = QRcode :: base64_png ($data, QRstr :: QR_ECLEVEL_L, 4, 2);
## Expected: $base64_data = data:image/png;base64,....
use QRcode\QRcode;
use QRcode\QRstr;
$data = 'Hello World!';
$base64_data = QRcode :: base64_webp ($data, QRstr :: QR_ECLEVEL_L, 4, 2);
## Expected: $base64_data = data:image/webp;base64,....
composer