PHP完全自学手册(珍藏版) 中文pdf扫描版下载
php生成短网址 像新浪微博的那种
<form action="urlShort.php" method="post">
<br style="color: rgb(0, 0, 0); font-family: 宋体; font-size: 14px; line-height: 25px; text-indent: 28px;" />
<span style="color: rgb(0, 0, 0); font-family: 宋体; font-size: 14px; line-height: 25px; text-indent: 28px;"><span style="color: rgb(0, 0, 0); font-family: 宋体; font-size: 14px; line-height: 25px; text-indent: 28px;">
<input name="url" onblur="if(this.value==''){this.value='输入网址'};" onfocus="if(this.value=='输入网址'){this.value='';}" size="16" type="text" value="输入网址" /></span>
<br style="color: rgb(0, 0, 0); font-family: 宋体; font-size: 14px; line-height: 25px; text-indent: 28px;" />
<span style="color: rgb(0, 0, 0); font-family: 宋体; font-size: 14px; line-height: 25px; text-indent: 28px;"><input type="submit" value=" 生成 " /></span></span></form>
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; } function url_short($url){ $url = crc32($url); $result = sprintf("%u",$url); return base62($result); } echo ("生成的新网址为: ".url_short($_POST['url'])." ");
转载请注明:谷谷点程序 » php生成短网址 像新浪微博的那种