html.php 1.7 KB

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