Home Backend Development PHP Tutorial PHP online generated QR code code example (google api)

PHP online generated QR code code example (google api)

Jul 13, 2017 am 11:01 AM
api php Example

QR code is also called QR Code. QR stands for Quick Response. It is a very popular coding method on mobile devices in recent years. It is better than the traditional Bar Code. Barcodes can store more information and represent more data types.

Two-dimensional bar code/QR code (2-dimensional bar code) is a black and white graphic that uses a specific geometric figure distributed on a plane (in a two-dimensional direction) according to certain rules to record data symbol information. ; In coding, the concept of "0" and "1" bit streams that form the basis of computer internal logic is cleverly used, and several geometric shapes corresponding to binary are used to represent text numerical information, through image input equipment or photoelectric scanning The equipment automatically reads to realize automatic processing of information: it has some common features of barcode technology: each code system has its own specific character set; each character occupies a certain width; it has certain verification functions, etc. At the same time, it also has the function of automatically identifying different lines of information and processing graphic rotation change points.

This article mainly introduces the example of generating QR code online through Google's API to generate QR code online. The code is as follows:

<!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.jbxue.com</title> 
<SCRIPT LANGUAGE=JavaScript> 
function post(){ 
if(document.getElementById(&#39;content&#39;).value==&#39;&#39;){alert(&#39;内容不能为空!&#39;);document.getElementById(&#39;content&#39;).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"><p class="er"> 
<?php 
$content=$_GET[&#39;content&#39;]; 
$width=$_GET[&#39;width&#39;]?$_GET[&#39;width&#39;]:300; 
$height=$_GET[&#39;height&#39;]?$_GET[&#39;height&#39;]: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, &#39;utf-8&#39;, &#39;gb2312&#39;)).""; 
echo "<img id=qrcode_img src=https://chart.googleapis.com/chart?cht=qr&chld=H&chs={$width}x{$height}&chl={$wen} /><br /> 
图片地址:<a href=&#39;https://chart.googleapis.com/chart?cht=qr&chld=H&chs={$width}x{$height}&chl={$wen}&#39; target=&#39;_blank&#39;>https://chart.googleapis.com/chart?cht=qr&chld=H&chs={$width}x{$height}&chl={$wen}</a><br /> 
复制发给你的朋友。 <a href=&#39;javascript:history.go(-1);&#39;>返回上一页</a>"; 
}else{ 
?> (脚本学堂 编辑整理 www.jbxue.com)
<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><? }?> 
<p></body></html>
Copy after login

The above is the detailed content of PHP online generated QR code code example (google api). For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

CakePHP Project Configuration CakePHP Project Configuration Sep 10, 2024 pm 05:25 PM

In this chapter, we will understand the Environment Variables, General Configuration, Database Configuration and Email Configuration in CakePHP.

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

CakePHP Date and Time CakePHP Date and Time Sep 10, 2024 pm 05:27 PM

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

CakePHP File upload CakePHP File upload Sep 10, 2024 pm 05:27 PM

To work on file upload we are going to use the form helper. Here, is an example for file upload.

CakePHP Routing CakePHP Routing Sep 10, 2024 pm 05:25 PM

In this chapter, we are going to learn the following topics related to routing ?

Discuss CakePHP Discuss CakePHP Sep 10, 2024 pm 05:28 PM

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

CakePHP Creating Validators CakePHP Creating Validators Sep 10, 2024 pm 05:26 PM

Validator can be created by adding the following two lines in the controller.

See all articles