html.php 1.4 KB

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