PHP在线生成二维码代码(google api)
程序员文章站
2022-05-21 17:23:02
复制代码 代码如下:
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>二维码生成-www.ibtf.net</title>
<script language=javascript>
function post(){
if(document.getelementbyid('content').value==''){alert('内容不能为空!');document.getelementbyid('content').focus();return false;}
if(ckregdatapost()==false){return false;}
}
</script>
</head>
<body>
<style>
body{text-align:center;background:#f5f5f5;line-height:22px;font-size:14px;color:#888;}
.newcrop{margin:10;}
.er{width:700px;margin:0px auto;border:1px solid gray}
span{background:#645;color:#fff}
body form {text-align:center;padding: 3px 6px 3px 6px;}
input.txt{color: #00008b;background-color: #add8e6;border: 1px inset #00008b;width: 200px;}
input.btn {color: #00008b;background-color: #add8e6;border: 1px outset #00008b;padding: 2px 4px 2px 4px;}
input.smallinput{border:1 solid black;font-size: 9pt; font-style: normal; font-variant: normal; font-weight: normal; height: 18px; line-height: normal}
</style>
<body class="newcrop"><div class="er">
<?php
$content=$_get['content'];
$width=$_get['width']?$_get['width']:300;
$height=$_get['height']?$_get['height']:300;
if($content){
echo "你输入的文字是: <span>$content </span><br />";
echo "你选择的宽度是: <span>$width </span><br />";
echo "你选择的高度是: <span>$height </span><br /> ";
echo "生成的二维码图像是:<br /> ";
$wen = urlencode(mb_convert_encoding($content, 'utf-8', 'gb2312'))."";
echo "<img id=qrcode_img src=https://chart.googleapis.com/chart?cht=qr&chld=h&chs={$width}x{$height}&chl={$wen} /><br />
图片地址:<a href='https://chart.googleapis.com/chart?cht=qr&chld=h&chs={$width}x{$height}&chl={$wen}' target='_blank'>https://chart.googleapis.com/chart?cht=qr&chld=h&chs={$width}x{$height}&chl={$wen}</a><br />
复制发给你的朋友。 <a href='javascript:history.go(-1);'>返回上一页</a>";
}else{
?>
<form action="" method="get" onsubmit="return post();">
<h1>
二维码生成工具</h1>
<p>width:<select name="width">
<option value="100">100</option>
<option value="200">200</option>
<option value="300" selected>300</option>
<option value="400">400</option>
<option value="500">500</option>
</select>
height: <select name="height">
<option value="100">100</option>
<option value="200">200</option>
<option value="300" selected>300</option>
<option value="400">400</option>
<option value="500">500</option>
</select></p>
输入网址或者文字:<br />
<textarea rows="5" cols="30" name="content" id="content" ></textarea>
<br /><br />
<input type="submit" value="生成图片" /> <input type="reset" value="重新填写">
<br />
</form><? }?>
<div></body></html>
复制代码 代码如下:
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>二维码生成-www.ibtf.net</title>
<script language=javascript>
function post(){
if(document.getelementbyid('content').value==''){alert('内容不能为空!');document.getelementbyid('content').focus();return false;}
if(ckregdatapost()==false){return false;}
}
</script>
</head>
<body>
<style>
body{text-align:center;background:#f5f5f5;line-height:22px;font-size:14px;color:#888;}
.newcrop{margin:10;}
.er{width:700px;margin:0px auto;border:1px solid gray}
span{background:#645;color:#fff}
body form {text-align:center;padding: 3px 6px 3px 6px;}
input.txt{color: #00008b;background-color: #add8e6;border: 1px inset #00008b;width: 200px;}
input.btn {color: #00008b;background-color: #add8e6;border: 1px outset #00008b;padding: 2px 4px 2px 4px;}
input.smallinput{border:1 solid black;font-size: 9pt; font-style: normal; font-variant: normal; font-weight: normal; height: 18px; line-height: normal}
</style>
<body class="newcrop"><div class="er">
<?php
$content=$_get['content'];
$width=$_get['width']?$_get['width']:300;
$height=$_get['height']?$_get['height']:300;
if($content){
echo "你输入的文字是: <span>$content </span><br />";
echo "你选择的宽度是: <span>$width </span><br />";
echo "你选择的高度是: <span>$height </span><br /> ";
echo "生成的二维码图像是:<br /> ";
$wen = urlencode(mb_convert_encoding($content, 'utf-8', 'gb2312'))."";
echo "<img id=qrcode_img src=https://chart.googleapis.com/chart?cht=qr&chld=h&chs={$width}x{$height}&chl={$wen} /><br />
图片地址:<a href='https://chart.googleapis.com/chart?cht=qr&chld=h&chs={$width}x{$height}&chl={$wen}' target='_blank'>https://chart.googleapis.com/chart?cht=qr&chld=h&chs={$width}x{$height}&chl={$wen}</a><br />
复制发给你的朋友。 <a href='javascript:history.go(-1);'>返回上一页</a>";
}else{
?>
<form action="" method="get" onsubmit="return post();">
<h1>
二维码生成工具</h1>
<p>width:<select name="width">
<option value="100">100</option>
<option value="200">200</option>
<option value="300" selected>300</option>
<option value="400">400</option>
<option value="500">500</option>
</select>
height: <select name="height">
<option value="100">100</option>
<option value="200">200</option>
<option value="300" selected>300</option>
<option value="400">400</option>
<option value="500">500</option>
</select></p>
输入网址或者文字:<br />
<textarea rows="5" cols="30" name="content" id="content" ></textarea>
<br /><br />
<input type="submit" value="生成图片" /> <input type="reset" value="重新填写">
<br />
</form><? }?>
<div></body></html>
上一篇: 闲言需要男女拥有银子