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: