二维码是二维条形码的一种,可以将网址、文字、照片等信息通过相应的编码算法编译成为一个方块形条码图案,手机用户可以通过摄像头和解码软件将相关信息重新解码并查看内容.
php类库PHP QR Code
两句话解释:# 包含qrlib.php的话需要同其它文件放到一起,文件、文件夹,phpqrcode.php是合并后版本,只需要包含这个文件,但生成的图片速度慢而且不太准确.
以下给出两种用法,代码如下:
<?php include('./phpqrcode/phpqrcode.php'); // 二维码数据 $data = 'http://gz.altmi.com'; // 生成的文件名 $filename = $errorCorrectionLevel.'|'.$matrixPointSize.'.png'; // 纠错级别:L、M、Q、H $errorCorrectionLevel = 'L'; // 点的大小:1到10 $matrixPointSize = 4; QRcode::png($data, $filename, $errorCorrectionLevel, $matrixPointSize, 2); # 创建一个二维码文件 QRcode::png('code data text', 'filename.png'); // creates file # 生成图片到浏览器 QRcode
::png('some othertext 1234'); // creates code image and outputs it directly into browser
如果生成有色彩的需要自己动手修改phpqrcode.php中QRimage类的image方法中颜色设置部分的代码,1.1.4版本的代码在第987、988行,一个前景色,一个背景色,代码如下:
$col[0] = ImageColorAllocate($base_image,255,255,255);
$col[1] = ImageColorAllocate($base_image,0,0,0); 即可.
利用 google开放api生成,代码如下:
<?php $urlToEncode="http://gz.altmi.com"; generateQRfromGoogle($urlToEncode); function generateQRfromGoogle($chl,$widhtHeight ='150',$EC_level='L',$margin='0') { $url = urlencode($url); echo '<img src="/static/imghwm/default1.png" data-src="http://chart.apis.google.com/chart?chs='.$widhtHeight.'x'.$widhtHeight.'&cht=qr&chld='.$EC_level.'|'.$margin.'&chl='.$chl.'" class="lazy" alt="QR code" widhtHeight="'.$size.'" widhtHeight="'.$size.'"/>'; }
教程地址:
欢迎转载!但请带上文章地址^^

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

Dreamweaver CS6
Visual web development tools

WebStorm Mac version
Useful JavaScript development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software
