Php generates QR code instance code

Source: Internet
Author: User
Php generates QR code instance code

What is a QR code? A qr code is a two-dimensional barcode. you can compile the URL, text, photos, and other information into a square-shaped barcode pattern using the corresponding encoding algorithm, mobile phone users can re-decode the related information and view the content through cameras and decoding software. # Two sentences: # put qrlib. php together with other files: files and folders. # Phpqrcode. php is a merged version. you only need to include this file, but the generated image is slow and inaccurate # the following two methods are provided:

  1. Include ('./phpqrcode. php ');
  2. // QR code data
  3. $ Data = 'http: // bbs.it-home.org ';
  4. // Generated file name
  5. $ Filename = $ errorCorrectionLevel. '| '.w.matrixpointsize.'.png ';
  6. // Error correction level: L, M, Q, H
  7. $ ErrorCorrectionLevel = 'l ';
  8. // Vertex size: 1 to 10
  9. $ MatrixPointSize = 4;
  10. QRcode: png ($ data, $ filename, $ errorCorrectionLevel, $ matrixPointSize, 2 );
  11. ?>
  12. # Create a QR code file
  13. QRcode: png ('code data text', 'filename.png ');
  14. // Creates file
  15. # Generating images to the browser
  16. QRcode: png ('Some othertext 1234 ');
  17. // Creates code image and outputs it directly into browser

If you generate a colorful phpqrcode, you must manually modify it. the color setting part of the QRimage class image method in php. the version 1.1.4 contains lines 987th and 988, a foreground color and a background color:

  1. $ Col [0] = ImageColorAllocate ($ base_image, 255,255,255 );
  2. $ Col [1] = ImageColorAllocate ($ base_image, 0, 0 );

For usage of QRcode, refer to the article: php generates a QR code library (QRCode method), and php generates a QR code image class QRcode.

2. use google open api to generate

  1. $ UrlToEncode = "http://bbs.it-home.org ";
  2. GenerateQRfromGoogle ($ urlToEncode );
  3. Function generateQRfromGoogle ($ chlorophyll, $ widhtHeight = '000000', $ EC_level = 'l', $ margin = '0 ')
  4. {
  5. $ Url = urlencode ($ url );
  6. Echo '';
  7. }

For details about how to generate a QR code using google APIs, refer to: php to call the google interface to generate a QR code instance.

Address: http://phpqrcode.sourceforge.net/Download: http://sourceforge.net/projects/phpqrcode/ 3. libqrencode address: http://fukuchi.org/works/qrencode/index.en.html php support see: http://hirokawa.netflowers.jp/entry/4900/

4. QRcode Perl CGI & PHP scripts address: http://www.swetake.com/qr/qr_cgi.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.