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('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"><p 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} / alt="PHP online generated QR code code example (google api)" ><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{ ?> (脚本学堂 编辑整理 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>
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!

php把负数转为正整数的方法:1、使用abs()函数将负数转为正数,使用intval()函数对正数取整,转为正整数,语法“intval(abs($number))”;2、利用“~”位运算符将负数取反加一,语法“~$number + 1”。

实现方法:1、使用“sleep(延迟秒数)”语句,可延迟执行函数若干秒;2、使用“time_nanosleep(延迟秒数,延迟纳秒数)”语句,可延迟执行函数若干秒和纳秒;3、使用“time_sleep_until(time()+7)”语句。

php字符串有下标。在PHP中,下标不仅可以应用于数组和对象,还可应用于字符串,利用字符串的下标和中括号“[]”可以访问指定索引位置的字符,并对该字符进行读写,语法“字符串名[下标值]”;字符串的下标值(索引值)只能是整数类型,起始值为0。

php除以100保留两位小数的方法:1、利用“/”运算符进行除法运算,语法“数值 / 100”;2、使用“number_format(除法结果, 2)”或“sprintf("%.2f",除法结果)”语句进行四舍五入的处理值,并保留两位小数。

在php中,可以使用substr()函数来读取字符串后几个字符,只需要将该函数的第二个参数设置为负值,第三个参数省略即可;语法为“substr(字符串,-n)”,表示读取从字符串结尾处向前数第n个字符开始,直到字符串结尾的全部字符。

判断方法:1、使用“strtotime("年-月-日")”语句将给定的年月日转换为时间戳格式;2、用“date("z",时间戳)+1”语句计算指定时间戳是一年的第几天。date()返回的天数是从0开始计算的,因此真实天数需要在此基础上加1。

方法:1、用“str_replace(" ","其他字符",$str)”语句,可将nbsp符替换为其他字符;2、用“preg_replace("/(\s|\ \;||\xc2\xa0)/","其他字符",$str)”语句。

查找方法:1、用strpos(),语法“strpos("字符串值","查找子串")+1”;2、用stripos(),语法“strpos("字符串值","查找子串")+1”。因为字符串是从0开始计数的,因此两个函数获取的位置需要进行加1处理。


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Dreamweaver CS6
Visual web development tools

Notepad++7.3.1
Easy-to-use and free code editor

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 English version
Recommended: Win version, supports code prompts!

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment