Home > Backend Development > PHP Tutorial > PHP class library for generating QR codes (QRCode method)

PHP class library for generating QR codes (QRCode method)

WBOY
Release: 2016-07-25 08:57:18
Original
1245 people have browsed it
  1. include "phpqrcode/phpqrcode.php";
  2. $value="http://bbs.it-home.org";
  3. $errorCorrectionLevel = "L";
  4. $matrixPointSize = "4 ";
  5. QRcode::png($value, false, $errorCorrectionLevel, $matrixPointSize);
  6. exit;
  7. ?>
Copy code

File output QR code:

  1. < ?php
  2. include('phpqrcode/phpqrcode.php');
  3. // QR code data
  4. $data = 'http://s.bookphone.cn';
  5. // Generated file name
  6. $filename = '1111 .png';
  7. // Error correction level: L, M, Q, H
  8. $errorCorrectionLevel = 'L';
  9. // Point size: 1 to 10
  10. $matrixPointSize = 4;
  11. QRcode::png($data , $filename, $errorCorrectionLevel, $matrixPointSize, 2);
  12. ?>
Copy the code

to generate a QR code with a logo in the middle:

  1. //QR code with middle logo

  2. //by bbs.it-home.org
  3. include('phpqrcode/phpqrcode.php');
  4. $ value='http://bbs.it-home.org';
  5. $errorCorrectionLevel = 'L';
  6. $matrixPointSize = 6;
  7. QRcode::png($value, 'jbxue.png', $errorCorrectionLevel, $matrixPointSize , 2);
  8. echo "QR code generated"."
    ";
  9. $logo = 'logo.png';
  10. $QR = 'jbxue.png';

  11. {

  12. $QR = imagecreatefromstring(file_get_contents($QR));

  13. $logo = imagecreatefromstring(file_get_contents($logo));
  14. $QR_width = imagesx($QR);
  15. $QR_height = imagesy($QR);
  16. $logo_width = imagesx($logo);
  17. $logo_height = imagesy($logo);
  18. $logo_qr_width = $QR_width / 5;
  19. $scale = $logo_width / $logo_qr_width;
  20. $logo_qr_height = $logo_height / $scale;
  21. $from_width = ($QR_width - $logo_qr_width) / 2;
  22. imagecopyresampled($QR, $logo, $from_width, $from_width, 0, 0, $ logo_qr_width, $logo_qr_height, $logo_width, $logo_height);
  23. }
  24. imagepng($QR,'jbxue_log.png');
  25. ?>
Copy code


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template