Using the PHP QR code class library to create a QR code
Using an example browser output:
<? Include "phpqrcode/phpqrcode.php"; $value = "Http://s.bookphone.cn/chinabook/index.php/adminhtml/Croles/admin"; $errorCorrectionLevel = "L"; $matrixPointSize = "4"; QRCode::p ng ($value, False, $errorCorrectionLevel, $matrixPointSize); Exit;?>
File output two-dimensional code
Include (' phpqrcode/phpqrcode.php ');
Two-dimensional code data
$data = ' http://s.bookphone.cn ';
The generated file name
$filename = ' 1111.png ';
Error correction level: L, M, Q, H
$errorCorrectionLevel = ' L ';
Size of point: 1 to 10
$matrixPointSize = 4;
QRCode::p ng ($data, $filename, $errorCorrectionLevel, $matrixPointSize, 2);
Create a two-dimensional code with logo in the middle
<?php include (' phpqrcode/phpqrcode.php '); $value = ' http://xy.bookphone.cn '; $errorCorrectionLevel = ' L '; $matrixPointSize = 6; QRCode::p ng ($value, ' xiangyang.png ', $errorCorrectionLevel, $matrixPointSize, 2); echo "QR code generated". " <br/> "; $logo = ' logo.png '; $QR = ' xiangyang.png '; if ($logo!== FALSE) {$QR = Imagecreatefromstring (file_get_contents ($QR)); $logo = Imagecreatefromstring (file_get_ Contents ($logo)); $QR _width = Imagesx ($QR); $QR _height = Imagesy ($QR); $logo _width = Imagesx ($logo); $logo _height = Imagesy ($logo); $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; Imagecopyresampled ($QR, $logo, $from _width, $from _width, 0, 0, $logo _qr_width, $logo _qr_height, $logo _width, $logo _ height); } imagepng ($QR, ' xiangyanglog.png ');?>