html.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. /**
  3. * HTML output example
  4. *
  5. * @created 21.12.2017
  6. * @author Smiley <smiley@chillerlan.net>
  7. * @copyright 2017 Smiley
  8. * @license MIT
  9. */
  10. declare(strict_types=1);
  11. use chillerlan\QRCode\{QRCode, QROptions};
  12. use chillerlan\QRCode\Data\QRMatrix;
  13. use chillerlan\QRCode\Output\QRMarkupHTML;
  14. require_once '../vendor/autoload.php';
  15. $options = new QROptions;
  16. $options->version = 5;
  17. $options->outputInterface = QRMarkupHTML::class;
  18. $options->cssClass = 'qrcode';
  19. $options->moduleValues = [
  20. // finder
  21. QRMatrix::M_FINDER_DARK => '#A71111', // dark (true)
  22. QRMatrix::M_FINDER_DOT => '#A71111', // finder dot, dark (true)
  23. QRMatrix::M_FINDER => '#FFBFBF', // light (false)
  24. // alignment
  25. QRMatrix::M_ALIGNMENT_DARK => '#A70364',
  26. QRMatrix::M_ALIGNMENT => '#FFC9C9',
  27. ];
  28. $out = (new QRCode($options))->render('https://www.youtube.com/watch?v=dQw4w9WgXcQ');
  29. header('Content-Type: text/html; charset=utf-8');
  30. ?>
  31. <!DOCTYPE html>
  32. <html lang="en">
  33. <head>
  34. <meta charset="UTF-8"/>
  35. <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
  36. <title>QRCode HTML Example</title>
  37. <style>
  38. div.qrcode{
  39. margin: 1em;
  40. }
  41. /* rows */
  42. div.qrcode > div {
  43. height: 10px;
  44. }
  45. /* modules */
  46. div.qrcode > div > span {
  47. display: inline-block;
  48. width: 10px;
  49. height: 10px;
  50. }
  51. </style>
  52. </head>
  53. <body>
  54. <?php echo $out; ?>
  55. </body>
  56. </html>