We want to generate two-dimensional code need to use a number of class libraries to achieve, I introduce the PHP QR code to generate two-dimensional code bar, the generation method is very simple, I would like to introduce the following.
PHP class library using PHP QR code to implement, do not need to install additional PHP extensions, first download the class library package, and sometimes address can not open, address: http://phpqrcode.sourceforge.net/
Download:
Domestic Download: http://www.jb51.net/codes/189897.html
Download abroad: http://sourceforge.net/projects/phpqrcode/
example, create a two-dimensional code using the PHP QR code class library.
1, browser output:
?
Include "phpqrcode/phpqrcode.php";
$value = "Http://www.jb51.net";
$errorCorrectionLevel = "L";
$matrixPointSize = "4";
QRCode::p ng ($value, False, $errorCorrectionLevel, $matrixPointSize);
Exit;
? >
2, file output two-dimensional code
Include (' phpqrcode/phpqrcode.php ');
Two-dimensional code data
$data = ' http://www.jb51.net ';
The generated filename
$filename = ' 1111.png ';
Error correction level: L, M, Q, H
$errorCorrectionLevel = ' l ';
The size of the point: 1 to ten
$matrixPointSize = 4;
QRCode::p ng ($data, $filename, $errorCorrectionLevel, $matrixPointSize, 2);
3, generate the middle with a logo two-dimensional code
<?php include (' phpqrcode/phpqrcode.php ');
$value = ' http://www.jb51.net ';
$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 '); ?