html.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. /**
  3. * @created 21.12.2017
  4. * @author Smiley <smiley@chillerlan.net>
  5. * @copyright 2017 Smiley
  6. * @license MIT
  7. */
  8. namespace chillerlan\QRCodeExamples;
  9. use chillerlan\QRCode\{QRCode, QROptions};
  10. use chillerlan\QRCode\Data\QRMatrix;
  11. use chillerlan\QRCode\Common\EccLevel;
  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. div.qrcode{
  23. margin: 5em;
  24. }
  25. /* rows */
  26. div.qrcode > div {
  27. height: 10px;
  28. }
  29. /* modules */
  30. div.qrcode > div > span {
  31. display: inline-block;
  32. width: 10px;
  33. height: 10px;
  34. }
  35. </style>
  36. </head>
  37. <body>
  38. <?php
  39. $data = 'https://www.youtube.com/watch?v=dQw4w9WgXcQ';
  40. $options = new QROptions([
  41. 'version' => 5,
  42. 'outputType' => QRCode::OUTPUT_MARKUP_HTML,
  43. 'eccLevel' => EccLevel::L,
  44. 'cssClass' => 'qrcode',
  45. 'moduleValues' => [
  46. // finder
  47. QRMatrix::M_FINDER | QRMatrix::IS_DARK => '#A71111', // dark (true)
  48. QRMatrix::M_FINDER => '#FFBFBF', // light (false)
  49. QRMatrix::M_FINDER_DOT | QRMatrix::IS_DARK => '#A71111', // finder dot, dark (true)
  50. // alignment
  51. QRMatrix::M_ALIGNMENT | QRMatrix::IS_DARK => '#A70364',
  52. QRMatrix::M_ALIGNMENT => '#FFC9C9',
  53. // timing
  54. QRMatrix::M_TIMING | QRMatrix::IS_DARK => '#98005D',
  55. QRMatrix::M_TIMING => '#FFB8E9',
  56. // format
  57. QRMatrix::M_FORMAT | QRMatrix::IS_DARK => '#003804',
  58. QRMatrix::M_FORMAT => '#00FB12',
  59. // version
  60. QRMatrix::M_VERSION | QRMatrix::IS_DARK => '#650098',
  61. QRMatrix::M_VERSION => '#E0B8FF',
  62. // data
  63. QRMatrix::M_DATA | QRMatrix::IS_DARK => '#4A6000',
  64. QRMatrix::M_DATA => '#ECF9BE',
  65. // darkmodule
  66. QRMatrix::M_DARKMODULE | QRMatrix::IS_DARK => '#080063',
  67. // separator
  68. QRMatrix::M_SEPARATOR => '#AFBFBF',
  69. // quietzone
  70. QRMatrix::M_QUIETZONE => '#DDDDDD',
  71. ],
  72. ]);
  73. echo (new QRCode($options))->render($data);
  74. ?>
  75. </body>
  76. </html>