mirror of
https://github.com/chillerlan/php-qrcode.git
synced 2026-10-05 03:17:02 +00:00
:octocat: examples cleanup
This commit is contained in:
+10
-9
@@ -6,23 +6,19 @@
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
namespace chillerlan\QRCodeExamples;
|
||||
|
||||
use chillerlan\QRCode\{QRCode, QROptions};
|
||||
use chillerlan\QRCode\Common\EccLevel;
|
||||
use chillerlan\QRCode\Data\QRMatrix;
|
||||
|
||||
require_once __DIR__.'/../vendor/autoload.php';
|
||||
|
||||
$data = 'https://www.youtube.com/watch?v=dQw4w9WgXcQ';
|
||||
|
||||
$options = new QROptions([
|
||||
'version' => 7,
|
||||
'outputType' => QRCode::OUTPUT_EPS,
|
||||
'eccLevel' => EccLevel::L,
|
||||
'scale' => 5,
|
||||
'addQuietzone' => true,
|
||||
'cachefile' => __DIR__.'/test.eps',
|
||||
# 'cachefile' => __DIR__.'/test.eps', // save to file
|
||||
'moduleValues' => [
|
||||
// finder
|
||||
QRMatrix::M_FINDER | QRMatrix::IS_DARK => 0xA71111, // dark (true)
|
||||
@@ -52,11 +48,16 @@ $options = new QROptions([
|
||||
],
|
||||
]);
|
||||
|
||||
// if viewed in the browser, we should push it as file download as EPS isn't usually supported
|
||||
header('Content-type: application/postscript');
|
||||
header('Content-Disposition: filename="qrcode.eps"');
|
||||
|
||||
echo (new QRCode($options))->render($data);
|
||||
if(php_sapi_name() !== 'cli'){
|
||||
// if viewed in the browser, we should push it as file download as EPS isn't usually supported
|
||||
header('Content-type: application/postscript');
|
||||
header('Content-Disposition: filename="qrcode.eps"');
|
||||
}
|
||||
|
||||
echo (new QRCode($options))->render('https://www.youtube.com/watch?v=dQw4w9WgXcQ');
|
||||
|
||||
exit;
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user