AutoCAD 3DMAX C语言 Pro/E UG JAVA编程 PHP编程 Maya动画 Matlab应用 Android
Photoshop Word Excel flash VB编程 VC编程 Coreldraw SolidWorks A Designer Unity3D
 首页 > PHP编程

一个php短网址的生成代码(仿微博短网址)

51自学网 2016-09-17 http://www.wanshiok.com
 <!DOCTYPE html><html lang="en"><head><meta charset="utf-8" /><title>urlShort</title></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></body></html><?phpheader("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);} www.jbxue.com$show .= $s;$x = floor($x/62);}return $show;}//生成短网址function url_short($url){$url = crc32($url);$result = sprintf("%u",$url);return base62($result);}echo ("生成短网址为:<a href='http://$_POST[url]'>".url_short($_POST['url'])."</a>");



说明
:本教程来源互联网或网友上传或出版商,仅为学习研究或媒体推广,wanshiok.com不保证资料的完整性。
 
上一篇:php分页类代码  下一篇:类的重写