text.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. /**
  3. *
  4. * @filesource text.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 __DIR__.'/../vendor/autoload.php';
  14. $data = 'https://www.youtube.com/watch?v=DLzxrzFCyOs&t=43s';
  15. $options = new QROptions([
  16. 'version' => 5,
  17. 'outputType' => QRCode::OUTPUT_STRING_TEXT,
  18. 'eccLevel' => QRCode::ECC_L,
  19. ]);
  20. // <pre> to view it in a browser
  21. echo '<pre style="font-size: 75%; line-height: 1;">'.(new QRCode($options))->render($data).'</pre>';
  22. // custom values
  23. $options = new QROptions([
  24. 'version' => 5,
  25. 'outputType' => QRCode::OUTPUT_STRING_TEXT,
  26. 'eccLevel' => QRCode::ECC_L,
  27. 'moduleValues' => [
  28. // finder
  29. 1536 => 'A', // dark (true)
  30. 6 => 'a', // light (false)
  31. // alignment
  32. 2560 => 'B',
  33. 10 => 'b',
  34. // timing
  35. 3072 => 'C',
  36. 12 => 'c',
  37. // format
  38. 3584 => 'D',
  39. 14 => 'd',
  40. // version
  41. 4096 => 'E',
  42. 16 => 'e',
  43. // data
  44. 1024 => 'F',
  45. 4 => 'f',
  46. // darkmodule
  47. 512 => 'G',
  48. // separator
  49. 8 => 'h',
  50. // quietzone
  51. 18 => '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>';