html.php 1.7 KB

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