PHP生成二维码

2013-6-19 liyangweb.com 李杨 PHP

转自《php100》,对几处小bug做了修改。

二维码现在搞的是很火热,那里都能看到扫一扫的身影,那么PHP如何生成二维码呢?请看下文~~~

<!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>二维码生成</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=isset($_GET['content'])?$_GET['content']:'';
        $width=isset($_GET['width'])?$_GET['width']:300;	
        $height=isset($_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($content);	
           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="生成图片"  /> &nbsp;&nbsp;&nbsp;<INPUT TYPE="RESET" VALUE="重新填写">
        <br /> 
        </form>
    <?php }?>
    <div>
</body>
</html>

 

标签: 二维码

评论:

lapthelakes
2019-01-18 06:58
<a href="http://www.divyangmart.com/kobe-11-zoom-poster-nike-runninge">kobe 11 zoom poster nike</a> <a href="http://www.ezellhvac.com/adidas-springblade-corriendo-zapatos-mujeres-quilt-schuhea">adidas springblade corriendo zapatos mujeres quilt</a> <a href="http://www.oldoyopark.com/maschio-nike-air-max-tailwind-8-gituttio-arancia-scarpeb">maschio nike air max tailwind 8 gituttio arancia</a> <a href="http://www.racquetlady.com/nike-air-max-95-green-spain-shoeso">nike air max 95 green spain</a> <a href="http://www.ankaralokanta.com/air-jordan-7-retro-wei%C3%9F-metalleic-gold-schwarz-edition-kurpesc">air jordan 7 retro wei脽 metalleic gold schwarz edition</a> <a href="http://www.mengenmetal.com/under-armour-contain-duffel-ii-zapatost">under armour contain duffel ii</a>
lapthelakes http://www.lapthelakes.com/
clickexplosions
2019-01-03 11:57
<a href="http://www.dreamybelize.net/nike-air-max-2015-gr%C3%B8n-valleey-kurpesa">nike air max 2015 gr酶n valleey</a> <a href="http://www.drspa.net/air-jordan-2-low-hvid-gum-kurpesc">air jordan 2 low hvid gum</a> <a href="http://www.dumaworks.net/nike-air-max-ultra-alle-schwarz-obuva">nike air max ultra alle schwarz</a> <a href="http://www.dylanhassinger.net/nike-dynamo-free-ps-ni%C3%B1os-amarillo-naranja-schuhef">nike dynamo free ps ni帽os amarillo naranja</a> <a href="http://www.emergexplanning.net/nike-sb-dunk-mid-dark-obsidian-thunder-nero-chaussuresg">nike sb dunk mid dark obsidian thunder nero</a> <a href="http://www.emtecsolution.net/nike-free-tr-6-print-kvinders-training-sko-obuvd">nike free tr 6 print kvinders training sko</a>
clickexplosions http://www.clickexplosions.net/
rebeccastaste
2019-01-01 20:09
<a href="http://www.myfraimz.com/air-jordan-11-grigio-rosa-scarpeb">air jordan 11 grigio rosa</a> <a href="http://www.winnercells.com/nike-air-max-95-green-spain-shoeso">nike air max 95 green spain</a> <a href="http://www.atppest.com/air-jordan-imminent-minzgr%C3%BCn-blau-kurpesb">air jordan imminent minzgr眉n blau</a> <a href="http://www.windriftbar.com/basketball-player-shoes-list-zapatost">basketball player shoes list</a> <a href="http://www.kidtokidboise.com/custom-painted-converse-uk-shoesz">custom painted converse uk</a> <a href="http://www.mesmertronic.com/nike-free-inneva-tech-military-gr%C3%B8nn-schuhec">nike free inneva tech military gr酶nn</a>
rebeccastaste http://www.rebeccastaste.com/
captmollie
2018-12-28 14:53
<a href="http://www.intotheglos.com/nike-air-max-bw-amarillo-gris-butyf">nike air max bw amarillo gris</a> <a href="http://www.myslinc.com/cubs-9-javier-baez-blue-long-sleeve-stitched-mlb-jersey-nflx">cubs 9 javier baez blue long sleeve stitched mlb jersey</a> <a href="http://www.shamankin.com/nike-zoom-winflo-2-r%C3%B8d-hair-butye">nike zoom winflo 2 r酶d hair</a> <a href="http://www.singingtoons.com/nike-free-herre-champs-kurpesd">nike free herre champs</a> <a href="http://www.snowdayrealty.com/ralph-lauren-polo-shirts-mesh-light-blu-maschio-polow">ralph lauren polo shirts mesh light blu maschio</a> <a href="http://www.totesoftware.com/nike-shox-jaune-vert-butyf">nike shox jaune vert</a>
[url=http://www.captmollie.com/]captmollie[/url]

发表评论:

Powered by emlog 冀ICP备13011830号-1