html.php 1.4 KB

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