php调用google接口生成二维码示例

yipeiwu_com6年前PHP代码库
复制代码 代码如下:

<?php
$data = isset($_GET['t']) ? $_GET['t'] : 'http://www.XXX.com';
$size = isset($_GET['size']) ? $_GET['size'] : '150x150';
$logo = isset($_GET['logo']) ? $_GET['logo'] :"./image/logo.jpg";

$chl = urlencode($logo);
$png = "http://chart.googleapis.com/chart?chs=$size&cht=qr&chl=$chl&chld=L|1&choe=UTF-8";
$QR = imagecreatefrompng($png);//外面那QR图
if ($logo !== FALSE) {
$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);
}
header('Content-type: image/png');
imagepng($QR);

imagedestroy($QR);
?>

相关文章

汇总PHPmailer群发Gmail的常见问题

大家在PHPmailer群发Gmail时会遇到许多常见问题,下面为大家总结了一些常见问题,希望对大家的学习有所帮助。 1.Could not authenticate 首先,如果你没有使...

基于PHP实现的多元线性回归模拟曲线算法

基于PHP实现的多元线性回归模拟曲线算法

本文实例讲述了基于PHP实现的多元线性回归模拟曲线算法。分享给大家供大家参考,具体如下: 多元线性回归模型: y = b1x1 + b2x2 + b3x3 +...... +bnxn;...

php ignore_user_abort与register_shutdown_function 使用方法

语法: int ignore_user_abort(int [setting]); 返回值: 整数 函数种类: PHP 系统功能 内容说明 0 - NORMAL(正常)1 - ABORT...

PHP中spl_autoload_register()函数用法实例详解

本文实例分析了PHP中spl_autoload_register()函数用法。分享给大家供大家参考,具体如下: 在了解这个函数之前先来看另一个函数:__autoload。 一、__aut...

功能齐全的PHP发送邮件类代码附详细说明

<?php  class Email {  //---设置全局变量  var $mailTo = "...