mirror of
https://github.com/chillerlan/php-qrcode.git
synced 2026-08-17 19:01:05 +00:00
:octocat: multi mode example
This commit is contained in:
+2
-1
@@ -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
|
||||
|
||||
@@ -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;
|
||||
Reference in New Issue
Block a user