当前位置:Gxlcms > PHP教程 > 仿微博php生成短网址,仿微博php_PHP教程

仿微博php生成短网址,仿微博php_PHP教程

时间:2021-07-01 10:21:17 帮助过:4人阅读

仿微博php生成短网址,仿微博php


html code

DOCTYPE html>  
<html lang="en">  
<head>  
  <meta charset="utf-8" />  
  <title>urlShorttitle>  
head>  
  
<body>  
  <form action="urlShort.php" method="post">  
    <input type="text" size="16" name="url" value="输入网址" onfocus="if(this.value=='输入网址'){this.value='';}" onblur="if(this.value==''){this.value='输入网址'};">  
    <input type="submit" value=" 生成 " />  
  form>  <a href="http://hovertree.com">何问起a>
body>  
html>  

php code

php  
     header("Content-Type:text/html;charset=UTF-8");    
     function base62($x){  
        $show = '';  
        while($x>0){  
            $s = $x % 62;  
            if ($s > 35){  
                $s = chr($s + 61);  
            }else if ($s > 5 && $S<=35){  
                $s = chr($s + 55);  
            }  
            $show .= $s;  
            $x = floor($x/62);  
        }  
        return $show;  
    }  /* 何问起 hovertree.com */
      
    function url_short($url){  
        $url = crc32($url);  
        $result = sprintf("%u",$url);   
        return base62($result);  
    }  
      
    echo ("生成的新网址为:$_POST[url]'>".url_short($_POST['url'])."");  
?>

推荐:http://www.cnblogs.com/roucheng/p/3528396.html

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/1132464.htmlTechArticle仿微博php生成短网址,仿微博php html code ! DOCTYPE html html lang ="en" head meta charset ="utf-8" / title urlShort / title / head body form action ="urlShort.php" meth...

人气教程排行