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:
- Include ('./phpqrcode. php ');
- // QR code data
- $ Data = 'http: // bbs.it-home.org ';
- // Generated file name
- $ Filename = $ errorCorrectionLevel. '| '.w.matrixpointsize.'.png ';
- // Error correction level: L, M, Q, H
- $ ErrorCorrectionLevel = 'l ';
- // Vertex size: 1 to 10
- $ MatrixPointSize = 4;
- QRcode: png ($ data, $ filename, $ errorCorrectionLevel, $ matrixPointSize, 2 );
- ?>
-
- # Create a QR code file
- QRcode: png ('code data text', 'filename.png ');
- // Creates file
-
- # Generating images to the browser
- QRcode: png ('Some othertext 1234 ');
- // 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:
- $ Col [0] = ImageColorAllocate ($ base_image, 255,255,255 );
- $ 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
- $ UrlToEncode = "http://bbs.it-home.org ";
- GenerateQRfromGoogle ($ urlToEncode );
- Function generateQRfromGoogle ($ chlorophyll, $ widhtHeight = '000000', $ EC_level = 'l', $ margin = '0 ')
- {
- $ Url = urlencode ($ url );
- Echo '';
- }
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 |