:octocat: multi mode example

This commit is contained in:
smiley
2023-02-01 20:35:06 +01:00
parent 72878502b6
commit a9a3f69e50
2 changed files with 53 additions and 1 deletions
+2 -1
View File
@@ -9,7 +9,8 @@
- [FPDF](./fpdf.php): PDF output via [FPDF](http://www.fpdf.org/)
- [EPS](./eps.php): Encapsulated PostScript
- [String](./text.php): String output
- [QRCode Reader](./reader.php): a simple reader example
- [Multi mode](./multimode.php): a demostration of multi mode usage
- [QRCode reader](./reader.php): a simple reader example
## Advanced output examples
+51
View File
@@ -0,0 +1,51 @@
<?php
/**
* multimode.php
*
* @created 31.01.2023
* @author smiley <smiley@chillerlan.net>
* @copyright 2023 smiley
* @license MIT
*/
use chillerlan\QRCode\QRCode;
use chillerlan\QRCode\QROptions;
require_once __DIR__.'/../vendor/autoload.php';
// make sure we run in UTF-8
// ideally, this should be set in php.ini => internal_encoding/default_charset or mbstring.internal_encoding
mb_internal_encoding('UTF-8');
// please excuse the IDE yelling https://youtrack.jetbrains.com/issue/WI-66549
$options = new QROptions;
$options->imageBase64 = false;
$options->connectPaths = true;
$qrcode = (new QRCode($options))
->addNumericSegment('1312')
->addByteSegment("\n")
->addAlphaNumSegment('ACAB')
->addByteSegment("\n")
->addKanjiSegment('すべての警官はろくでなしです')
->addByteSegment("\n")
->addHanziSegment('所有警察都是混蛋')
->addByteSegment("\n")
->addByteSegment('https://www.bundesverfassungsgericht.de/SharedDocs/Pressemitteilungen/DE/2016/bvg16-036.html')
;
$render = $qrcode->render();
if(PHP_SAPI !== 'cli'){
header('Content-type: image/svg+xml');
if(extension_loaded('zlib')){
header('Vary: Accept-Encoding');
header('Content-Encoding: gzip');
$render = gzencode($render, 9);
}
}
echo $render;
exit;