<!DOCTYPE html>
<html><head><meta charset="utf-8"><title>QR Code 產生器</title>
<style>
body{font-family:Microsoft JhengHei,sans-serif;text-align:center;background:#f5f5f5;padding:20px}
.card{max-width:700px;margin:auto;background:#fff;padding:20px;border-radius:8px;box-shadow:0 2px 6px rgba(0,0,0,.1)}
input[type=text],textarea{width:100%;padding:10px;margin:8px 0;border:1px solid #ddd;border-radius:4px;box-sizing:border-box}
select{padding:8px;margin:0 10px}
button{padding:10px 24px;background:#007bff;color:#fff;border:none;border-radius:4px;cursor:pointer}
button:hover{background:#0056b3}
img{max-width:100%;border:1px solid #eee;margin:16px 0}
</style></head><body>
<div class="card">
<h2>QR Code 線上產生器</h2>
<?php
$content = $_GET['content'] ?? '';
$width = (int)($_GET['width'] ?? 300);
$height = (int)($_GET['height'] ?? 300);
if ($content !== '') {
$encoded = urlencode(mb_convert_encoding($content, 'UTF-8', 'auto'));
$api = "https://chart.googleapis.com/chart?cht=qr&chld=H&chs={$width}x{$height}&chl={$encoded}";
echo "<p>輸入內容:<strong>".htmlspecialchars($content)."</strong></p>";
echo "<p>尺寸:{$width} x {$height} px</p>";
echo "<img src='{$api}' alt='QR Code'>";
echo "<p><a href='{$api}' target='_blank'>直接開啟圖片連結</a></p>";
echo "<p><a href='javascript:history.back()'>← 重新產生</a></p>";
} else {
?>
<form method="get">
<p>
寬度:<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>
高度:<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>
<p>輸入文字或網址:<br><textarea name="content" rows="5" required></textarea></p>
<button type="submit">產生 QR Code</button>
<button type="reset">重置</button>
</form>
<?php } ?>
</div></body></html>
Google Chart API 已於 2019 年正式停止服務,建議改用:
phpqrcode)本地端產生