html.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <?php
  2. /**
  3. * @created 21.12.2017
  4. * @author Smiley <smiley@chillerlan.net>
  5. * @copyright 2017 Smiley
  6. * @license MIT
  7. */
  8. use chillerlan\QRCode\{QRCode, QROptions};
  9. use chillerlan\QRCode\Data\QRMatrix;
  10. require_once '../vendor/autoload.php';
  11. $options = new QROptions([
  12. 'version' => 5,
  13. 'outputType' => QRCode::OUTPUT_MARKUP_HTML,
  14. 'cssClass' => 'qrcode',
  15. 'eccLevel' => QRCode::ECC_L,
  16. 'moduleValues' => [
  17. // finder
  18. QRMatrix::M_FINDER_DARK => '#A71111', // dark (true)
  19. QRMatrix::M_FINDER_DOT => '#A71111',
  20. QRMatrix::M_FINDER => '#FFBFBF', // light (false)
  21. // alignment
  22. QRMatrix::M_ALIGNMENT_DARK => '#A70364',
  23. QRMatrix::M_ALIGNMENT => '#FFC9C9',
  24. // timing
  25. QRMatrix::M_TIMING_DARK => '#98005D',
  26. QRMatrix::M_TIMING => '#FFB8E9',
  27. // format
  28. QRMatrix::M_FORMAT_DARK => '#003804',
  29. QRMatrix::M_FORMAT => '#00FB12',
  30. // version
  31. QRMatrix::M_VERSION_DARK => '#650098',
  32. QRMatrix::M_VERSION => '#E0B8FF',
  33. // data
  34. QRMatrix::M_DATA_DARK => '#4A6000',
  35. QRMatrix::M_DATA => '#ECF9BE',
  36. // darkmodule
  37. QRMatrix::M_DARKMODULE => '#080063',
  38. // separator
  39. QRMatrix::M_SEPARATOR => '#AFBFBF',
  40. // quietzone
  41. QRMatrix::M_QUIETZONE => '#FFFFFF',
  42. ],
  43. ]);
  44. header('Content-Type: text/html; charset=utf-8');
  45. ?>
  46. <!DOCTYPE html>
  47. <html lang="en">
  48. <head>
  49. <meta charset="UTF-8"/>
  50. <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
  51. <title>QRCode test</title>
  52. <style>
  53. body{
  54. margin: 1em;
  55. padding: 0;
  56. }
  57. div.qrcode{
  58. margin: 0;
  59. padding: 0;
  60. }
  61. /* rows */
  62. div.qrcode > div {
  63. margin: 0;
  64. padding: 0;
  65. height: 10px;
  66. }
  67. /* modules */
  68. div.qrcode > div > span {
  69. display: inline-block;
  70. width: 10px;
  71. height: 10px;
  72. }
  73. div.qrcode > div > span {
  74. background-color: #ccc;
  75. }
  76. </style>
  77. </head>
  78. <body>
  79. <?php
  80. echo (new QRCode($options))->render('https://www.youtube.com/watch?v=dQw4w9WgXcQ');
  81. ?>
  82. </body>
  83. </html>