新秀企业网站系统PHP版是一款简洁易用、方便二次开发的PHP企业网站系统。后台功能齐全,操作简便,可开启伪静态和纯静态模式,有利于SEO优化;前台可设置成同时显示多国语言,适合用于外贸企业建站;程序代码清晰简洁,可扩展性良好,安全可靠。新秀企业网站系统PHP版可免费下载使用,可用于商业用途,没有功能和时效限制,除版权标识外,所有代码都允许修改。后台功能简介:1.基本设置:基本信息,联系方式,网站设
导读:在二维码广泛应用化的今天,在web站点中自动生成对应的二维码是最基础的需求。文章介绍了使用PHP自动生成二维码的三种方式。
get方法实现方式一:
$urlToEncode="163.com";
generateQRfromGoogle($urlToEncode);
function generateQRfromGoogle($chl,$widhtHeight ='150',$EC_level='L',$margin='0')
{
$url = urlencode($url);
return ' ';
}
post方法实现方式:
$width = 300;
$height = 300;
$string = "163.com";
function qrcode($width,$height,$string)
{
$post_data = array();
$post_data['cht'] = 'qr';
$post_data['chs'] = $width."x".$height;
$post_data['chl'] = $string;
$post_data['choe'] = "UTF-8";
$url = "http://chart.apis.google.com/chart";
$data_Array = array();
foreach($post_data as $key => $value)
{
$data_Array[] = $key.'='.$value;
}
$data = implode("&",$data_Array);
//echo $data;
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POSTFIELDS,$data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
//echo " "; 注意,不写header的写法
return $result; }
header("Content-type:image/png");
echo qrcode($width,$height,$string);
2.利用php类库PHP QR Code来实现
首先下载类库包
地址:http://phpqrcode.sourceforge.net/
下载:http://sourceforge.net/projects/phpqrcode/
-
API文档
-
详细的例子
include "./phpqrcode/phpqrcode.php";
$value="http://www.weste.net";
$errorCorrectionLevel = "L";
$matrixPointSize = "4";
QRcode::png($value, false, $errorCorrectionLevel, $matrixPointSize);
exit;
?>










