How PHP uses Phpqrcode to generate two-dimensional code

Source: Internet
Author: User

Phpqrcode is a foreign one to generate two-dimensional code of the class library, to facilitate the generation of two-dimensional code, user-friendly access to mobile phone users.

Download Address: Http://xz6.jb51.net:81/201407/yuanma/phpqrcode (jb51.net). rar

Download first, then unzip to your project

Download, unzip the public folder in my project publicly

I hope that we can learn from the significance

The code is as follows:

Include (' public/phpqr/phpqrcode.php ');//introduce PHP QR library file relative path $value = ' Someone said: Love a person will humble to dust, and then bloom. '; Two-dimensional code content $errorCorrectionLevel = ' L ';//fault tolerance level $matrixPointSize = 6;//Generate picture size//Generate two-dimensional code picture QRCode::p ng ($value, ' qrcode.png 
	', $errorCorrectionLevel, $matrixPointSize, 2); $logo = ' public/images/logo.jpg '; the prepared logo picture $QR = ' qrcode.png ';//The original two-dimensional code graph if ($logo!== FALSE) {$QR = 
	    Imagecreatefromstring (file_get_contents ($QR)); 
	    $logo = imagecreatefromstring (file_get_contents ($logo));  
	    $QR _width = Imagesx ($QR);//Two-dimensional code picture width $QR _height = Imagesy ($QR);//two-dimensional code picture height $logo _width = imagesx ($logo);//logo Picture width 
	    $logo _height = Imagesy ($logo);//logo picture height $logo _qr_width = $QR _width/5; 
	    $scale = $logo _width/$logo _qr_width; 
	    $logo _qr_height = $logo _height/$scale; 
	    $from _width = ($QR _width-$logo _qr_width)/2;  Regroup pictures and resize imagecopyresampled ($QR, $logo, $from _width, $from _width, 0, 0, $logo _qr_width, $logo _qr_height, $logo _width, $Logo_height); 
	///Output Picture imagepng ($QR, ' helloweba.png '); Echo '  ';
Note: Base_url is the project path setting in CI

If you want to do a link to the two-dimensional code, you need to connect to the real site for the full path, such as Baidu: https://www.baidu.com/

Can be realized, the mobile phone sweep a sweep network to get the hidden content of two-dimensional code.

As shown in figure:





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.