html.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. use chillerlan\QRCode\Data\QRMatrix;
  13. use chillerlan\QRCode\Common\EccLevel;
  14. require_once '../vendor/autoload.php';
  15. header('Content-Type: text/html; charset=utf-8');
  16. ?>
  17. <!DOCTYPE html>
  18. <html lang="en">
  19. <head>
  20. <meta charset="UTF-8"/>
  21. <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
  22. <title>QRCode test</title>
  23. <style>
  24. div.qrcode{
  25. margin: 5em;
  26. }
  27. /* rows */
  28. div.qrcode > div {
  29. height: 10px;
  30. }
  31. /* modules */
  32. div.qrcode > div > span {
  33. display: inline-block;
  34. width: 10px;
  35. height: 10px;
  36. }
  37. </style>
  38. </head>
  39. <body>
  40. <?php
  41. $data = 'https://www.youtube.com/watch?v=DLzxrzFCyOs&t=43s';
  42. $options = new QROptions([
  43. 'version' => 5,
  44. 'outputType' => QRCode::OUTPUT_MARKUP_HTML,
  45. 'eccLevel' => EccLevel::L,
  46. 'cssClass' => 'qrcode',
  47. 'moduleValues' => [
  48. // finder
  49. QRMatrix::M_FINDER | QRMatrix::IS_DARK => '#A71111', // dark (true)
  50. QRMatrix::M_FINDER => '#FFBFBF', // light (false)
  51. QRMatrix::M_FINDER_DOT | QRMatrix::IS_DARK => '#A71111', // finder dot, dark (true)
  52. // alignment
  53. QRMatrix::M_ALIGNMENT | QRMatrix::IS_DARK => '#A70364',
  54. QRMatrix::M_ALIGNMENT => '#FFC9C9',
  55. // timing
  56. QRMatrix::M_TIMING | QRMatrix::IS_DARK => '#98005D',
  57. QRMatrix::M_TIMING => '#FFB8E9',
  58. // format
  59. QRMatrix::M_FORMAT | QRMatrix::IS_DARK => '#003804',
  60. QRMatrix::M_FORMAT => '#00FB12',
  61. // version
  62. QRMatrix::M_VERSION | QRMatrix::IS_DARK => '#650098',
  63. QRMatrix::M_VERSION => '#E0B8FF',
  64. // data
  65. QRMatrix::M_DATA | QRMatrix::IS_DARK => '#4A6000',
  66. QRMatrix::M_DATA => '#ECF9BE',
  67. // darkmodule
  68. QRMatrix::M_DARKMODULE | QRMatrix::IS_DARK => '#080063',
  69. // separator
  70. QRMatrix::M_SEPARATOR => '#AFBFBF',
  71. // quietzone
  72. QRMatrix::M_QUIETZONE => '#DDDDDD',
  73. ],
  74. ]);
  75. echo (new QRCode($options))->render($data);
  76. ?>
  77. </body>
  78. </html>