Example of generating QR code (google api) online using PHP, googleapi

Source: Internet
Author: User

Example of generating QR code (google api) online using PHP, googleapi

Generate a QR code online using the api that generates a QR code online by google.

Code:

<! 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> QR code generation -www.jbxue.com </title>
<Script language = JavaScript>
Function post (){
If (document. getElementById ('content'). value = '') {alert ('content cannot be blank! '); 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: # background 8B; background-color: # ADD8E6; border: 1px outset # background 8B; 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 "the text you entered is: <span> $ content </span> <BR/> ";
Echo "the width you choose is: <span> $ width </span> <BR/> ";
Echo "the height you choose is: <span> $ height </span> <BR/> ";
Echo "the generated QR code image is: <BR/> ";
$ Wen = urlencode (mb_convert_encoding ($ content, 'utf-8', 'gb2312 '))."";
Echo " <br/>
Image address: <a href = 'https: // chart.googleapis.com/chart? Cht = qr & chld = H & chs = {$ width} x {$ height} & chlorophyll = {$ wen} 'target = '_ blank'> https://chart.googleapis.com/chart? Cht = qr & chld = H & chs = {$ width} x {$ height} & chlorophyll = {$ wen} </a> <br/>
Copy to your friends. <A href = 'javascript: history. go (-1); '> return to the previous page </a> ";
} Else {
?> (Edit www.jbxue.com)
<Form action = "" method = "get" onsubmit = "return post ();">
<H1>
QR code generation tool <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>
Enter the URL or text: <br/>
<Textarea rows = "5" cols = "30" name = "content" id = "content"> </textarea>
<Br/>
<Input type = "submit" value = "generate image"/> <input type = "RESET" VALUE = "Refill">
<Br/>
</Form> <? }?>
<Div> </body>
Why does the urlencode processing string in php use the Google QR code APi to generate Chinese characters for the QR code?

Baidu MP3 is encoded as GBK. In your code, UTF8 is encoded as GBK urlencode (& #39; footsteps & #39 ;) = % BD % C5 % B2 % BD encoded as UTF8 urlencode (& #39; footsteps & #39 ;) = % E8 % 84% 9A % E6 % AD % A5 you need to use the iconv function to go through
 
Is there code for generating QR codes on the PHP website? JAVA

PHP QRCODE
Try

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.