text.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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, QROptions};
  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' => QRCode::ECC_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' => QRCode::ECC_L,
  26. 'moduleValues' => [
  27. // finder
  28. 1536 => 'A', // dark (true)
  29. 6 => 'a', // light (false)
  30. // alignment
  31. 2560 => 'B',
  32. 10 => 'b',
  33. // timing
  34. 3072 => 'C',
  35. 12 => 'c',
  36. // format
  37. 3584 => 'D',
  38. 14 => 'd',
  39. // version
  40. 4096 => 'E',
  41. 16 => 'e',
  42. // data
  43. 1024 => 'F',
  44. 4 => 'f',
  45. // darkmodule
  46. 512 => 'G',
  47. // separator
  48. 8 => 'h',
  49. // quietzone
  50. 18 => 'i',
  51. ],
  52. ]);
  53. // <pre> to view it in a browser
  54. echo '<pre style="font-size: 75%; line-height: 1;">'.(new QRCode($options))->render($data).'</pre>';