PHP uses QRCode to easily scan and upload QR codes.

Source: Internet
Author: User
PHP uses QRCode to easily implement QR code scanning and downloading. as the Android platform starts, many excellent third-party app markets have emerged in China. they all provide a QR code downloading function, this is a user-friendly feature. you can use your HTC or Motorola Android mobile phone to enable WIFI, install a QR code scanning software, and use the camera to use PHP to easily scan and download QR codes.

With the launch of the Android platform, many excellent third-party app markets have emerged in China. they all provide a QR code download function, which is a user-friendly function, take your HTC or Motorola Android phone, turn on WIFI, install a QR code scanning software, use the camera function to scan the QR code, and then download and install it directly, some time ago, because of the website host of an Android app of the company, PHP was used to implement this function. This article will summarize and help friends who need this function.

There are already several implementation methods on the Internet, such as using Google open APIs and libqrencode. This article will mainly discuss how to use PHP's excellent open-source QRcode library to implement this function, which greatly simplifies our work, all we need to do is download the source code package and include it in your project. This function can be done with only one line of code.

1. download the source code package:

Address: http://phpqrcode.sourceforge.net/
Download: http://sourceforge.net/projects/phpqrcode/



2. introduce to your php file

    
 



There are two methods, one is to use qrlib. the php file reads all class libraries in the form of plug-ins, and the other is the phpqrcode. php file. this is a merged version. all the class libraries are included in this file. if your server has installed the APC cache, you can use this class library to improve efficiency.

The parameter configuration is directly modified in the qrconfig. php file. Generally, only two constants are modified.

Define ('QR _ cacheable', true); // whether to use cache define ('QR _ CACHE_DIR ', $ console. DIRECTORY_SEPARATOR. 'cache'); // modify your own cache directory to ensure that the directory is writable.



3. generate a QR code image

QRcode::png('http://www.pfanr.com/download/'.$pid.'.html','/data/webroot/images/ddd.png',); 




Input two parameters: the download address and the address generated by the QR code image ,? A line of code will deal with this user-friendly function.

Source from: http://www.itkuaixun.com/news/article/46171.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.