sample_html.php 980 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. require_once '../vendor/autoload.php';
  3. use codemasher\QRCode\QRCode;
  4. use codemasher\QRCode\QRConst;
  5. //---------------------------------------------------------
  6. $qrcode = new QRCode;
  7. print('<h4>明示的に型番を指定</h4>');
  8. // エラー訂正レベルを設定
  9. // QR_ERROR_CORRECT_LEVEL_L : 7%
  10. // QR_ERROR_CORRECT_LEVEL_M : 15%
  11. // QR_ERROR_CORRECT_LEVEL_Q : 25%
  12. // QR_ERROR_CORRECT_LEVEL_H : 30%
  13. $qrcode->setErrorCorrectLevel(QRConst::ERROR_CORRECT_LEVEL_L);
  14. // 型番(大きさ)を設定
  15. // 1~10
  16. $qrcode->setTypeNumber(3);
  17. // データ(文字列※)を設定
  18. // ※日本語はSJIS
  19. $qrcode->addData('QRコード');
  20. // QRコードを作成
  21. $qrcode->make();
  22. // HTML出力
  23. echo $qrcode->printHTML();
  24. //---------------------------------------------------------
  25. print('<h4>型番自動</h4>');
  26. // 型番が最小となるQRコードを作成
  27. $qr = $qrcode->getMinimumQRCode('QRコード', QRConst::ERROR_CORRECT_LEVEL_L);
  28. // HTML出力
  29. echo $qr->printHTML();