-
- $urlToEncode="http://gz.altmi.com";
- generateQRfromGoogle($urlToEncode);
- function generateQRfromGoogle($chl,$widhtHeight ='150',$EC_level='L',$margin ='0')
- {
- $url = urlencode($url);
- echo '';
- }
Copy code
2.php class library PHP QR Code
Address: http://phpqrcode.sourceforge.net/
Download: http://sourceforge.net/projects/phpqrcode/
Example:
-
- # Create a QR code file
- QRcode::png('code data text', 'filename.png');
- # Generate an image to the browser
- QRcode::png('some othertext 1234' );
Copy code
3.libqrencode
Address: http://fukuchi.org/works/qrencode/index.en.html
For php support, please refer to: http://hirokawa.netflowers.jp/entry/4900/
4.QRcode Perl CGI & php tutorial scripts
Address: http://www.swetake.com/qr/qr_cgi.html
Regarding the content of QR code generated by PHP, it is introduced in many PHP tutorials. Please study it carefully. After all, this thing is very popular now.
Let me share with you a complete example.
4. In the second method, add the logo in the middle of the QR code
Modify the png method in the QRimage class in phpqrcode.php:
-
- public static function png($frame, $filename = false, $pixelPerPoint = 4, $outerFrame = 4, $saveandprint=FALSE, $mergePic='')
- {
- $image = self::image ($frame, $pixelPerPoint, $outerFrame);
- if($mergePic) {
- $im = imagecreatefrompng($mergePic);
- $w = imagesx($im);
- $h = imagesy($im);
- ImageAlphaBlending ($image, true);
- ImageAlphaBlending($im, true);
- $qrw = (imagesx($image)-$w)/2;
- $qrh = (imagesy($image)-$h)/2;
- imagecopy($image, $im, $qrw, $qrh, 0, 0, $w, $h);
- imagedestroy($im);
- }
- if ($filename === false) {
- Header(" Content-type: image/png");
- ImagePng($image);
- } else {
- ImagePng($image, $filename);
- if($saveandprint===TRUE){
- header("Content-type: image/png");
- ImagePng($image);
- }
- }
- ImageDestroy($image);
- }
Copy code
|