text.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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 __DIR__.'/../vendor/autoload.php';
  13. $data = 'https://www.youtube.com/watch?v=DLzxrzFCyOs&t=43s';
  14. $options = new QROptions([
  15. 'version' => 5,
  16. 'outputType' => QRCode::OUTPUT_STRING_TEXT,
  17. 'eccLevel' => EccLevel::L,
  18. ]);
  19. // <pre> to view it in a browser
  20. echo '<pre style="font-size: 75%; line-height: 1;">'.(new QRCode($options))->render($data).'</pre>';
  21. // custom values
  22. $options = new QROptions([
  23. 'version' => 5,
  24. 'outputType' => QRCode::OUTPUT_STRING_TEXT,
  25. 'eccLevel' => EccLevel::L,
  26. 'moduleValues' => [
  27. // finder
  28. QRMatrix::M_FINDER | QRMatrix::IS_DARK => 'A', // dark (true)
  29. QRMatrix::M_FINDER => 'a', // light (false)
  30. QRMatrix::M_FINDER_DOT | QRMatrix::IS_DARK => 'ä', // finder dot, dark (true)
  31. // alignment
  32. QRMatrix::M_ALIGNMENT | QRMatrix::IS_DARK => 'B',
  33. QRMatrix::M_ALIGNMENT => 'b',
  34. // timing
  35. QRMatrix::M_TIMING | QRMatrix::IS_DARK => 'C',
  36. QRMatrix::M_TIMING => 'c',
  37. // format
  38. QRMatrix::M_FORMAT | QRMatrix::IS_DARK => 'D',
  39. QRMatrix::M_FORMAT => 'd',
  40. // version
  41. QRMatrix::M_VERSION | QRMatrix::IS_DARK => 'E',
  42. QRMatrix::M_VERSION => 'e',
  43. // data
  44. QRMatrix::M_DATA | QRMatrix::IS_DARK => 'F',
  45. QRMatrix::M_DATA => 'f',
  46. // darkmodule
  47. QRMatrix::M_DARKMODULE | QRMatrix::IS_DARK => 'G',
  48. // separator
  49. QRMatrix::M_SEPARATOR => 'h',
  50. // quietzone
  51. QRMatrix::M_QUIETZONE => 'i',
  52. ],
  53. ]);
  54. // <pre> to view it in a browser
  55. echo '<pre style="font-size: 75%; line-height: 1;">'.(new QRCode($options))->render($data).'</pre>';