PHP generates code for two-dimensional code instances

Source: Internet
Author: User

What is a two-dimensional code? Two-dimensional code is a two-dimensional barcode, can be the URL, text, photos and other information through the corresponding encoding algorithm compiled into a block-shaped barcode pattern, mobile phone users can use the camera and decryption software to re-decode the relevant information and view the content. # Two words to explain: # contains qrlib.php words need to put together with other files: files, folders. # phpqrcode.php is a merged version that only needs to contain this file, but the resulting picture is slow and less accurate # Here are two ways to use:

    1. Include ('./phpqrcode/phpqrcode.php ');
    2. Two-dimensional code data
    3. $data = ' http://bbs.it-home.org ';
    4. The generated file name
    5. $filename = $errorCorrectionLevel. ' | '. $matrixPointSize. " PNG ';
    6. Error correction level: L, M, Q, H
    7. $errorCorrectionLevel = ' L ';
    8. Size of point: 1 to 10
    9. $matrixPointSize = 4;
    10. QRCode::p ng ($data, $filename, $errorCorrectionLevel, $matrixPointSize, 2);
    11. ?>
    12. # Create a two-dimensional code file
    13. QRCode::p ng (' Code data text ', ' filename.png ');
    14. Creates file
    15. # Generate image to browser
    16. QRCode::p ng (' some othertext 1234 ');
    17. Creates code image and outputs it directly into browser
Copy Code

If you generate color-coded code that requires you to modify the color settings section of the Qrimage class in Phpqrcode.php, 1.1.4 version of the Code on the No. 987, 988 lines, a foreground color, a background color:

    1. $col [0] = imagecolorallocate ($base _image,255,255,255);
    2. $col [1] = Imagecolorallocate ($base _image,0,0,0);
Copy Code

For the use of QRCode, you can also refer to the article: PHP generated two-dimensional Code class library (QRCode method), PHP generated two-dimensional code image class QRCode

2, build with Google Open API

    1. $urlToEncode = "http://bbs.it-home.org";
    2. Generateqrfromgoogle ($urlToEncode);
    3. function Generateqrfromgoogle ($chl, $widhtHeight = ' Max ', $EC _level= ' L ', $margin = ' 0 ')
    4. {
    5. $url = UrlEncode ($url);
    6. Echo ';
    7. }
Copy Code

The Google API to generate two-dimensional code, you can also refer to: PHP call Google interface to generate two-dimensional code instances, Google API generation QR code method

Address: http://phpqrcode.sourceforge.net/Download: Http://sourceforge.net/projects/phpqrcode/3.libqrencode Address:/http fukuchi.org/works/qrencode/index.en.html PHP Support Please refer to: 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.