example.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. /**
  3. * @filesource example.php
  4. * @created 10.12.2015
  5. * @author Smiley <smiley@chillerlan.net>
  6. * @copyright 2015 Smiley
  7. * @license MIT
  8. */
  9. require_once '../vendor/autoload.php';
  10. use chillerlan\QRCode\QRCode;
  11. use chillerlan\QRCode\Output\QRImage;
  12. use chillerlan\QRCode\Output\QRString;
  13. use chillerlan\QRCode\Output\QRStringOptions;
  14. $data = 'otpauth://totp/test?secret=B3JX4VCVJDVNXNZ5&issuer=chillerlan.net';
  15. #$data = 'https://www.youtube.com/watch?v=DLzxrzFCyOs&t=43s';
  16. #$data = 'skype://echo123';
  17. ?>
  18. <!DOCTYPE html>
  19. <html lang="en">
  20. <head>
  21. <meta charset="UTF-8"/>
  22. <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
  23. <title>QRCode test</title>
  24. <style>
  25. body{
  26. margin: 0;
  27. padding: 0;
  28. }
  29. div.qrcode{
  30. margin: 0 5px;
  31. }
  32. /* row element */
  33. div.qrcode > p {
  34. margin: 0;
  35. padding: 0;
  36. height: 5px;
  37. }
  38. /* column element(s) */
  39. div.qrcode > p > b,
  40. div.qrcode > p > i {
  41. display: inline-block;
  42. width: 5px;
  43. height: 5px;
  44. }
  45. div.qrcode > p > b {
  46. background-color: #000;
  47. }
  48. div.qrcode > p > i {
  49. background-color: #fff;
  50. }
  51. </style>
  52. </head>
  53. <body>
  54. <?php
  55. echo '<img class="qrcode" alt="qrcode" src="'.(new QRCode($data, new QRImage))->output().'" />';
  56. echo '<div class="qrcode">'.(new QRCode($data, new QRString))->output().'</div>';
  57. $qrStringOptions = new QRStringOptions;
  58. $qrStringOptions->type = QRCode::OUTPUT_STRING_TEXT;
  59. echo '<pre class="qrcode">'.(new QRCode($data, new QRString($qrStringOptions)))->output().'</pre>';
  60. ?>
  61. </body>
  62. </html>