PHP 2 ways to generate QR codes

Source: Internet
Author: User
Tags php class

The use of two-dimensional code I will not say, look at the two-dimensional code generated by PHP bar.

Using Google's API to generate QR codes, many foreign sites now offer such APIs

Look at the code. "======================="

<?php$urltoencode= "http://gz.altmi.com"; Generateqrfromgoogle ($urlToEncode); function Generateqrfromgoogle ($chl, $widhtHeight = ' Max ', $EC _level= ' L ', $margin = ' 0 ') {     $url = UrlEncode ($url);      Echo ' 

Chs= '. $widhtHeight. ' X '. $widhtHeight. ' &cht=qr&chld= '. $EC _level. ' | '. $margin. ' &chl= '. $chl. ' "alt=" QR Code "widhtheight=" '. $size. ' widhtheight= ' '. $size. ' /> '; }?>

The above method is particularly simple, but suppose that the site does not provide such an API, we do not want to break the food? Let's use our PHP class library.

PHP class library PHP QR Code
Address: http://phpqrcode.sourceforge.net/
Download: http://sourceforge.net/projects/phpqrcode/

Instance:

<?

PHP include ('./phpqrcode/phpqrcode.php '); Two-dimensional code data $data = ' http://gz.altmi.com '; The generated file name $filename = $errorCorrectionLevel. ' | '. $matrixPointSize. " PNG '; Error correction level: L, M, Q, H $errorCorrectionLevel = ' L '; The size of the point: 1 to $matrixPointSize = 4; QRCode::p ng ($data, $filename, $errorCorrectionLevel, $matrixPointSize, 2);?>

Official given use case: <?php# include one of these two files:/*qrlib.php for full version (also the All Libraries files form Package Plus cache dir) OR phpqrcode.php for merged version (only one file, but slower and less accurate code because disabled Cach Eand quicker masking configured) */# two sentences to explain: # including qrlib.php words need to be put together with other files: files, directories. # phpqrcode.php is the merged version number. Just need to include this file, but the resulting picture is slow and inaccurate # Here are two ways to use: # Create a QR code file QRCode::p ng (' Code data text ', ' filename.png ');//Creates file# Generate picture to browser QRCode::p ng (' some othertext 1234 ');//creates code image and outputs it directly into browser

hey. Can try to play on their own. Delmar on the list. If you don't give it, I'll send it.



PHP 2 ways to generate QR codes

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.